@softistx/alxia-graphql 0.0.0-stage → 0.20.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.
Files changed (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +445 -2
  3. package/dist/bounded-stream.d.ts +37 -0
  4. package/dist/bounded-stream.d.ts.map +1 -0
  5. package/dist/endpoint.d.ts +17 -0
  6. package/dist/endpoint.d.ts.map +1 -0
  7. package/dist/executor.d.ts +49 -0
  8. package/dist/executor.d.ts.map +1 -0
  9. package/dist/explorer.d.ts +24 -0
  10. package/dist/explorer.d.ts.map +1 -0
  11. package/dist/graphql.d.ts +63 -0
  12. package/dist/graphql.d.ts.map +1 -0
  13. package/dist/handler.d.ts +11 -0
  14. package/dist/handler.d.ts.map +1 -0
  15. package/dist/index.d.ts +8 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +621 -0
  18. package/dist/index.js.map +21 -0
  19. package/dist/once-per-request.d.ts +28 -0
  20. package/dist/once-per-request.d.ts.map +1 -0
  21. package/dist/operation.d.ts +3 -0
  22. package/dist/operation.d.ts.map +1 -0
  23. package/dist/options.d.ts +38 -0
  24. package/dist/options.d.ts.map +1 -0
  25. package/dist/removed.d.ts +14 -0
  26. package/dist/removed.d.ts.map +1 -0
  27. package/dist/sandbox.d.ts +15 -0
  28. package/dist/sandbox.d.ts.map +1 -0
  29. package/dist/testing/client.d.ts +95 -0
  30. package/dist/testing/client.d.ts.map +1 -0
  31. package/dist/testing/index.d.ts +2 -0
  32. package/dist/testing/index.d.ts.map +1 -0
  33. package/dist/testing/index.js +73 -0
  34. package/dist/testing/index.js.map +10 -0
  35. package/dist/ws.d.ts +30 -0
  36. package/dist/ws.d.ts.map +1 -0
  37. package/docs/README.md +31 -0
  38. package/docs/guide/context.md +351 -0
  39. package/docs/guide/endpoint.md +293 -0
  40. package/docs/guide/executor.md +75 -0
  41. package/docs/guide/ide.md +160 -0
  42. package/docs/guide/plugins.md +316 -0
  43. package/docs/guide/production.md +374 -0
  44. package/docs/guide/testing.md +171 -0
  45. package/docs/guide/websockets.md +329 -0
  46. package/docs/migrating-to-graxia.md +408 -0
  47. package/docs/roadmap.md +122 -0
  48. package/docs/troubleshooting.md +963 -0
  49. package/package.json +69 -5
@@ -0,0 +1,963 @@
1
+ # Troubleshooting
2
+
3
+ Each entry is headed by the text you see: a TypeScript error, an exception
4
+ thrown when the app is built, or a response from the endpoint. Problems that
5
+ show no message, or only the browser's, are under [Traps](#traps), by
6
+ symptom. Coming from the Yoga-based releases, read
7
+ [Migrating to graxia](migrating-to-graxia.md) first.
8
+
9
+ **Install**
10
+
11
+ - [`Cannot find package '@softistx/graxia' from '…/@softistx/alxia-graphql/dist/index.js'`](#cannot-find-package-softistxgraxia-from-softistxalxia-graphqldistindexjs)
12
+
13
+ **CSRF**
14
+
15
+ - [`CSRF_HEADER_REQUIRED`](#csrf_header_required)
16
+ - [`sameOrigin` or `renderSandbox` is not exported](#sameorigin-or-rendersandbox-is-not-exported)
17
+ - [`graphql(app, { logging })`, `requestId` or `cors` throws a `TypeError`](#graphqlapp--logging--requestid-or-cors-throws-a-typeerror)
18
+
19
+ **Types**
20
+
21
+ - [`the schema's resolvers read a context the app does not build: missing …`](#the-schemas-resolvers-read-a-context-the-app-does-not-build-missing-)
22
+ - [`Property 'viewer' does not exist on type '{ readonly '~error': "GraphQLContext needs the type of an app: GraphQLContext<typeof app>"; } & GraphQLWsContext'`](#property-viewer-does-not-exist-on-type--readonly-error-graphqlcontext-needs-the-type-of-an-app-graphqlcontexttypeof-app---graphqlwscontext)
23
+ - [`Property 'viewer' does not exist on type 'CoreContext'`](#property-viewer-does-not-exist-on-type-corecontext)
24
+ - [`Property 'query' does not exist on type 'CoreContext & ServerContext<…>'`](#property-query-does-not-exist-on-type-corecontext--servercontext)
25
+ - [`Type 'true' is not assignable to type 'GraphiQLOptions | GraphiQLOptionsFactory<…> | undefined'`](#type-true-is-not-assignable-to-type-graphiqloptions--graphiqloptionsfactory--undefined)
26
+ - [`'graphqlEndpoint' does not exist in type 'GraphQLOptions<…>'`](#graphqlendpoint-does-not-exist-in-type-graphqloptions)
27
+ - [``Type '"gql"' is not assignable to type '`/${string}`'``](#type-gql-is-not-assignable-to-type-string)
28
+
29
+ **Startup**
30
+
31
+ - [`TypeError: GET /graphql is declared twice`](#typeerror-get-graphql-is-declared-twice)
32
+ - [`GraxiaConfigError: limits.bodyBytes must be a positive integer`](#graxiaconfigerror-limitsbodybytes-must-be-a-positive-integer)
33
+ - [`TypeError: graphql(app, { ws: { keepAlive: 0 } }): keepAlive is the milliseconds between pings, a positive number up to 2147483647, or false for none`](#typeerror-graphqlapp--ws--keepalive-0---keepalive-is-the-milliseconds-between-pings-a-positive-number-up-to-2147483647-or-false-for-none)
34
+
35
+ **Responses**
36
+
37
+ - [`200 {"errors":[{"message":"Unexpected error.", … "code":"INTERNAL_SERVER_ERROR"}}]}`](#200-errorsmessageunexpected-error--codeinternal_server_error)
38
+ - [`403 CSRF_HEADER_REQUIRED` from the test client](#403-csrf_header_required-from-the-test-client)
39
+ - [`PersistedQueryNotFound` or `PersistedQueryNotSupported`](#persistedquerynotfound-or-persistedquerynotsupported)
40
+ - [`405 {"error":"method_not_allowed"}` on `OPTIONS /graphql`](#405-errormethod_not_allowed-on-options-graphql)
41
+ - [`405 {"errors":[{"message":"Can only perform a mutation operation from a POST request."}]}`](#405-errorsmessagecan-only-perform-a-mutation-operation-from-a-post-request)
42
+ - [`406` with an empty body](#406-with-an-empty-body)
43
+ - [`413 … "code":"BODY_TOO_LARGE"` on `POST /graphql`](#413--codebody_too_large-on-post-graphql)
44
+ - [`415 … "code":"UNSUPPORTED_MEDIA_TYPE"`](#415--codeunsupported_media_type)
45
+ - [`Subscriptions are not supported over this transport (subscriptions.sse is false).`](#subscriptions-are-not-supported-over-this-transport-subscriptionssse-is-false)
46
+ - [`The operation was aborted.` from `graphqlExecutor`](#the-operation-was-aborted-from-graphqlexecutor)
47
+ - [`Syntax Error: Document contains more than 15000 tokens. Parsing aborted.`](#syntax-error-document-contains-more-than-15000-tokens-parsing-aborted)
48
+ - [`Syntax Error: Document is nested more than 1000 levels deep. Parsing aborted.`](#syntax-error-document-is-nested-more-than-1000-levels-deep-parsing-aborted)
49
+ - [`Syntax Error: Document is nested too deeply to parse.`](#syntax-error-document-is-nested-too-deeply-to-parse)
50
+ - [`{"errors":[{"message":"Must provide a query string."}]}`](#errorsmessagemust-provide-a-query-string)
51
+ - [A WebSocket closes with 4400 after the first message](#a-websocket-closes-with-4400-after-the-first-message)
52
+ - [`The Sec-WebSocket-Protocol header must offer "graphql-transport-ws".`](#the-sec-websocket-protocol-header-must-offer-graphql-transport-ws-400-subprotocol_required)
53
+
54
+ **Traps**
55
+
56
+ - [The endpoint answers without a guard declared after it](#the-endpoint-answers-without-a-guard-declared-after-it)
57
+ - [graxia's parse, validate or resolver spans are missing](#graxias-parse-validate-or-resolver-spans-are-missing)
58
+ - [The logger, CORS or secure headers miss the endpoint](#the-logger-cors-or-secure-headers-miss-the-endpoint)
59
+ - [An anonymous request to a missing path is a 401](#an-anonymous-request-to-a-missing-path-is-a-401)
60
+ - [A WebSocket client cannot connect: `Expected 101 status code`](#a-websocket-client-cannot-connect-expected-101-status-code)
61
+ - [Every WebSocket operation is refused by a client-header check](#every-websocket-operation-is-refused-by-a-client-header-check)
62
+ - [An idle subscription over SSE is reset after about 10 seconds](#an-idle-subscription-over-sse-is-reset-after-about-10-seconds)
63
+ - [unmet peer `@softistx/graxia` from `@softistx/graxia-graphiql`](#unmet-peer-softistxgraxia-from-softistxgraxia-graphiql)
64
+ - [The IDE page is blank](#the-ide-page-is-blank)
65
+ - [GraphiQL is served in production](#graphiql-is-served-in-production)
66
+ - [GraphiQL does not open in development, or in a test](#graphiql-does-not-open-in-development-or-in-a-test)
67
+
68
+ ## Install
69
+
70
+ ### `Cannot find package '@softistx/graxia' from '…/@softistx/alxia-graphql/dist/index.js'`
71
+
72
+ **When:** importing `@softistx/alxia-graphql`, before any of your code runs. The same
73
+ message names `@softistx/graxia-graphiql` or `graphql` when that one is missing; `tsc`
74
+ reports either as `TS2307: Cannot find module '@softistx/graxia'`.
75
+
76
+ **Why:** `@softistx/graxia`, `@softistx/graxia-graphiql` and `graphql` are peers: the
77
+ package declares no dependency, so the app installs them.
78
+
79
+ **Fix:**
80
+
81
+ ```sh
82
+ bun add @softistx/alxia-graphql @softistx/graxia @softistx/graxia-graphiql graphql
83
+ ```
84
+
85
+ `@softistx/graxia` must be 0.10 or later. After a move from Yoga,
86
+ `bun remove graphql-yoga graphql-ws` ([Migrating to graxia](migrating-to-graxia.md)).
87
+
88
+ ## CSRF
89
+
90
+ ### `CSRF_HEADER_REQUIRED`
91
+
92
+ A `GET`, or a `POST` that is not JSON, was answered 403: it carries none of
93
+ the CSRF headers graxia asks for by default. Send one of `x-graphql-csrf`,
94
+ `graphql-require-preflight`, `apollo-require-preflight` or
95
+ `x-apollo-operation-name`, or set `csrf: false` on `graphql()`.
96
+
97
+ ### `sameOrigin` or `renderSandbox` is not exported
98
+
99
+ Both were removed with Yoga. The origin check is graxia's `csrf: { sameOrigin: true }`
100
+ (off by default; the CSRF header check is on); the Sandbox page is `ide: 'apollo-sandbox'`.
101
+
102
+ ### `graphql(app, { logging })`, `requestId` or `cors` throws a `TypeError`
103
+
104
+ These options were Yoga's and are gone. Unexpected failures go to
105
+ `onUnexpected` (`console.error`, off in production); log requests with
106
+ `@softistx/alxia-logger`; mount `@softistx/alxia-cors` on the app before `graphql()`.
107
+
108
+ ## Types
109
+
110
+ These are what `tsc` prints. Codes are those with `exactOptionalPropertyTypes`
111
+ off; with it on, an assignment error is `TS2375` instead of `TS2322`, with
112
+ the same last line.
113
+
114
+ ### `the schema's resolvers read a context the app does not build: missing …`
115
+
116
+ **When:** `graphql(app, { schema })`, where `…` names a field: `missing user`,
117
+ `missing viewer`. With several missing, each is a member of a union.
118
+
119
+ ```text
120
+ error TS2322: Type 'GraphQLSchemaWithContext<…>' is not assignable to type 'GraphQLSchema & { _context?: … } & "the schema's resolvers read a context the app does not build: missing user"'.
121
+ ```
122
+
123
+ **Why:** the schema was typed with `GraphQLContext<typeof base>`, and its
124
+ resolvers read what `base`'s middlewares add, but `graphql` was given an app that
125
+ does not run those middlewares: another app, or the endpoint declared before the
126
+ `derive` or the guard.
127
+
128
+ **Fix:** mount the endpoint on the app the schema was typed from, after its
129
+ middlewares ([The typed context](guide/context.md)):
130
+
131
+ ```ts
132
+ const base = alxia().use(bearer({ jwt })); // adds user
133
+ const schema = createSchema<GraphQLContext<typeof base>>()({ … });
134
+ const app = base.plugin((app) => graphql(app, { schema })); // not alxia().plugin(…)
135
+ ```
136
+
137
+ **When the missing field comes from the `context` option** — `missing
138
+ loaders`, though `context` returns `loaders` — the function reads its
139
+ argument without a type annotation, so TypeScript does not infer what it
140
+ returns. Annotate the argument:
141
+
142
+ ```ts
143
+ graphql(app, {
144
+ schema,
145
+ context: ({ users }: GraphQLContext<typeof base>) => ({ loaders: createLoaders(users) }),
146
+ });
147
+ ```
148
+
149
+ ### `Property 'viewer' does not exist on type '{ readonly '~error': "GraphQLContext needs the type of an app: GraphQLContext<typeof app>"; } & GraphQLWsContext'`
150
+
151
+ **When:** a resolver of a schema typed `createSchema<GraphQLContext<X>>()`
152
+ reads a field, and `X` is not an alxia app: a function returning one, a
153
+ schema, a route. Passed to `graphql(app, { schema })` anyway, the schema is
154
+ refused with `missing ~error`.
155
+
156
+ **Why:** `GraphQLContext` reads the context from an app's type. Given
157
+ anything else, it is this message, and holds none of the app's fields.
158
+
159
+ **Fix:** give it the app's type:
160
+
161
+ ```ts
162
+ const makeApp = () => alxia().decorate({ users });
163
+ const base = makeApp();
164
+ createSchema<GraphQLContext<typeof base>>()({ … }); // not GraphQLContext<typeof makeApp>
165
+ ```
166
+
167
+ ### `Property 'viewer' does not exist on type 'CoreContext'`
168
+
169
+ **When:** a resolver of a schema created with `createSchema()({ … })`, no type
170
+ argument, reads what the app's middlewares add.
171
+
172
+ **Why:** an untyped schema's context is graxia's alone (`signal`). The field is there at
173
+ runtime; its type is not.
174
+
175
+ **Fix:**
176
+
177
+ ```ts
178
+ const schema = createSchema<GraphQLContext<typeof base>>()({ … });
179
+ ```
180
+
181
+ ### `Property 'query' does not exist on type 'CoreContext & ServerContext<…>'`
182
+
183
+ **When:** a resolver reads `query`, `headers`, `cookies`, `body`, `reply` or
184
+ `redirect` from its context, as a route handler would.
185
+
186
+ **Why:** those are the route's, and mean nothing to a resolver: the request
187
+ is a GraphQL request, and a resolver answers a field, not the request.
188
+ `params` is not there either: graxia no longer spreads the request, its
189
+ params, headers or cookies into the context.
190
+
191
+ **Fix:** read a header or a cookie from `request`, and set them on the
192
+ response with `set`:
193
+
194
+ ```ts
195
+ const resolvers = {
196
+ Query: {
197
+ locale: (_: unknown, __: unknown, { request, set }: GraphQLContext<typeof base>) => {
198
+ set.headers.set('vary', 'accept-language');
199
+ return request.headers.get('accept-language') ?? 'en';
200
+ },
201
+ },
202
+ };
203
+ ```
204
+
205
+ ### `Type 'true' is not assignable to type 'GraphiQLOptions | GraphiQLOptionsFactory<…> | undefined'`
206
+
207
+ **When:** `graphql(app, { schema, graphiql: true })`, or `false`.
208
+
209
+ **Why:** `ide` decides whether there is a GraphiQL; `graphiql` takes only
210
+ its options.
211
+
212
+ **Fix:**
213
+
214
+ ```ts
215
+ graphql(app, { schema, ide: 'graphiql', graphiql: { title: 'Users API' } });
216
+ graphql(app, { schema, ide: false });
217
+ ```
218
+
219
+ ### `'graphqlEndpoint' does not exist in type 'GraphQLOptions<…>'`
220
+
221
+ **When:** passing `graphqlEndpoint`, Yoga's option.
222
+
223
+ ```text
224
+ error TS2353: Object literal may only specify known properties, and 'graphqlEndpoint' does not exist in type 'GraphQLOptions<…>'.
225
+ ```
226
+
227
+ **Why:** the endpoint is a route of the app, and its path is joined to the
228
+ app's prefix; graxia is told the result.
229
+
230
+ **Fix:**
231
+
232
+ ```ts
233
+ graphql(app, { schema, path: '/gql' }); // served at <prefix>/gql
234
+ ```
235
+
236
+ ### ``Type '"gql"' is not assignable to type '`/${string}`'``
237
+
238
+ **When:** `path` does not start with `/`.
239
+
240
+ **Fix:**
241
+
242
+ ```ts
243
+ graphql(app, { schema, path: '/gql' });
244
+ ```
245
+
246
+ ## Startup
247
+
248
+ ### `TypeError: GET /graphql is declared twice`
249
+
250
+ **When:** building the app, at the second `graphql(…)` on it, or at a
251
+ `get('/graphql', …)` beside the endpoint.
252
+
253
+ **Why:** each `graphql` call declares `GET` and `POST` at its `path`, and
254
+ two endpoints with the default path collide. `plugin((app) => graphql(app, …))`
255
+ declares the routes on the app it is called on, so calling it twice on the
256
+ same `base` — for two variants of an app — declares them twice there.
257
+
258
+ **Fix:** a `path` for each endpoint, or one `graphql` per app:
259
+
260
+ ```ts
261
+ const app = alxia()
262
+ .plugin((app) => graphql(app, { schema }))
263
+ .plugin((app) => graphql(app, { schema: admin, path: '/admin/graphql' }));
264
+ ```
265
+
266
+ For two variants on one base, build each on a fork of it
267
+ ([Several apps on one base](../../core/docs/guide/groups-and-plugins.md#several-apps-on-one-base-fork)):
268
+
269
+ ```ts
270
+ import { defineMiddleware } from '@softistx/alxia';
271
+ import { graphql } from '@softistx/alxia-graphql';
272
+ import { base } from './context';
273
+ import { schema } from './schema';
274
+
275
+ export const app = base.fork().plugin((app) => graphql(app, { schema }));
276
+ const fakeViewer = defineMiddleware((_ctx, next) => next({ viewer: { id: 'ada' } }));
277
+ const testApp = base.fork().use(fakeViewer).plugin((app) => graphql(app, { schema }));
278
+ ```
279
+
280
+ ### `TypeError: graphql(app, { ws: { keepAlive: 0 } }): keepAlive is the milliseconds between pings, a positive number up to 2147483647, or false for none`
281
+
282
+ **When:** declaring `graphql(app, { ws: { keepAlive } })` with `0`, a
283
+ negative number, `NaN` or `Infinity` — anything but a finite positive number; the message names the value given.
284
+
285
+ **Why:** `keepAlive` is the interval of each socket's pings: `0` would
286
+ ping in a loop.
287
+
288
+ **Fix:** give the milliseconds between pings, or `false` for none:
289
+
290
+ ```ts
291
+ graphql(app, { schema, ws: { keepAlive: 30_000 } });
292
+ ```
293
+
294
+ ### `GraxiaConfigError: limits.bodyBytes must be a positive integer`
295
+
296
+ **When:** declaring `graphql(app, { bodyLimit })` (or `limits: { bodyBytes }`)
297
+ with `0`, a negative number, a fraction, `NaN`, `Infinity` or a string.
298
+
299
+ **Why:** `bodyLimit` is graxia's `limits.bodyBytes`, a count of bytes that
300
+ graxia checks where `graphql()` is declared.
301
+
302
+ **Fix:** a positive whole number of bytes:
303
+
304
+ ```ts
305
+ graphql(app, { schema, bodyLimit: 5 * 1024 * 1024 });
306
+ ```
307
+
308
+ ### `Subscriptions are not supported over this transport (subscriptions.sse is false).`
309
+
310
+ **When:** `graphqlExecutor(...)` is given a document whose operation is a
311
+ subscription; the answer is `{ errors: [{ extensions: { code:
312
+ 'SUBSCRIPTION_NOT_SUPPORTED' } }] }`, graxia's refusal.
313
+
314
+ **Why:** the executor answers once, with the endpoint's JSON body. A
315
+ subscription streams.
316
+
317
+ **Fix:** serve the subscription through `graphql(app, { schema })` (SSE, or
318
+ `ws: true`), and use the executor for queries and mutations
319
+ ([guide](guide/executor.md)).
320
+
321
+ ### `Too many requests, try again later.` (`RATE_LIMITED`, 429)
322
+
323
+ **When:** an operation selects a field given to `fieldRateLimit` more often
324
+ than its limit allows; nothing executed. `extensions.retryAfter` and the
325
+ `Retry-After` header are the wait in seconds. The code is `RATE_LIMITED`
326
+ unless the `code` option says otherwise (`TOO_MANY_ATTEMPTS`, say). Under
327
+ `batching` the refused element is an error in a 200 array with no
328
+ `Retry-After`: read `extensions.retryAfter`.
329
+
330
+ **Why:** every selection counts, aliases and fragments included, so one
331
+ request with 300 aliases costs 300, and the units spent before a refusal stay
332
+ spent.
333
+
334
+ **Fix:** wait, or raise the limit. A client that really needs several
335
+ selections sends them over several requests.
336
+
337
+ ### `<field> may be selected once per operation.` (`FIELD_SELECTED_ONCE`, 400)
338
+
339
+ **When:** a field declared `{ limit, single: true }` is written more than once
340
+ in the executed operation, with another response key or other arguments;
341
+ nothing is consumed. The same selection reached twice (through a fragment)
342
+ counts once.
343
+
344
+ **Fix:** select the field once per operation.
345
+
346
+ ### `GraxiaConfigError: fieldRateLimit: fields must be an object with at least one field name`
347
+
348
+ **When:** `fieldRateLimit` is declared with no `fields`, or with none inside.
349
+
350
+ **Fix:** name the fields to count: `fieldRateLimit({ fields: { signIn: limit } })`.
351
+
352
+ ### `GraxiaConfigError: fieldRateLimit: fields.signIn must be a limit ({ consume }) or { limit, single? }`
353
+
354
+ **When:** a field's value is neither a limit nor `{ limit, single? }`, a
355
+ `RateLimitStore` passed as it is, say. The name in the message is the field's.
356
+
357
+ **Fix:** adapt the store with `limitFromStore(store, { limit, windowMs })`, or
358
+ give an object with `consume(key, cost)`.
359
+
360
+ ### `GraxiaConfigError: fieldRateLimit: ipv6Prefix must be an integer from 0 to 128`
361
+
362
+ **When:** `ipv6Prefix` is not a whole number from 0 to 128.
363
+
364
+ **Fix:** use `64` for a subscriber's network, or leave it out to count each address.
365
+
366
+ ### `GraxiaConfigError: fieldRateLimit: ipv6Prefix only applies to the default key; reduce the address inside key() instead`
367
+
368
+ **When:** `fieldRateLimit` is given both `ipv6Prefix` and `key`.
369
+
370
+ **Fix:** drop one, or group the address in your own key with `ipv6Network` from `@softistx/alxia-rate-limit`.
371
+
372
+ ### `GraxiaConfigError: fieldRateLimit: code must be a non-empty string`
373
+
374
+ **When:** `code` is an empty string or not a string.
375
+
376
+ **Fix:** give the `extensions.code` you want, or leave it out for `RATE_LIMITED`.
377
+
378
+ ### `GraxiaConfigError: limitFromStore: limit must be an integer of 1 or more`
379
+
380
+ **When:** `limitFromStore` is given a `limit` or `windowMs` that is not a whole
381
+ number of 1 or more (the message names the one at fault).
382
+
383
+ **Fix:** give whole numbers of 1 or more.
384
+
385
+ ### `GraxiaConfigError: limitFromStore: no policy; pass { limit, windowMs } or give the store a policy`
386
+
387
+ **When:** the store has no `policy` and `limitFromStore` was not given both
388
+ `limit` and `windowMs`.
389
+
390
+ **Fix:** pass `{ limit, windowMs }`, or use a store that carries its policy.
391
+
392
+ ### `GraxiaConfigError: limitFromStore: limit 5 differs from the store policy's limit 3`
393
+
394
+ **When:** the numbers given disagree with the store's own `policy` (`limit` or
395
+ `windowMs`, the message names it and both values).
396
+
397
+ **Fix:** leave the policy out for a store that has one, or give the same numbers.
398
+
399
+ ### `The operation was aborted.` from `graphqlExecutor`
400
+
401
+ **When:** a call with a `signal` that aborted (before the call, or while it
402
+ ran) no longer rejects; a spec or a caller that expects a rejection fails.
403
+
404
+ **Why:** the executor resolves `{ errors: [{ extensions: { code: 'OPERATION_ABORTED' } }] }`,
405
+ with no `data`, as the endpoint answers a client that left.
406
+
407
+ **Fix:** read the code instead of catching:
408
+
409
+ ```ts
410
+ const { errors } = await execute(request, context, { signal });
411
+ if (errors?.[0]?.extensions?.code === 'OPERATION_ABORTED') return;
412
+ ```
413
+
414
+ ### `Syntax Error: Document contains more than 15000 tokens. Parsing aborted.`
415
+
416
+ **When:** a query is answered with `GRAPHQL_PARSE_FAILED` (400 under
417
+ `application/graphql-response+json`, 200 under `application/json`) and this
418
+ message.
419
+
420
+ **Why:** a document may hold 15 000 tokens by default (`limits.tokens`),
421
+ so that no request makes the server parse and keep an unbounded one. A
422
+ generated query or a screen with many inlined fragments can pass it; a
423
+ client that worked before is refused.
424
+
425
+ **Fix:** raise the limit to what your largest real query needs, or turn it
426
+ off. Persisted operations keep clients from sending large documents at all
427
+ ([Persisted operations](guide/production.md#persisted-operations-briefly)):
428
+
429
+ ```ts
430
+ graphql(app, { schema, limits: { tokens: 30_000 } }); // or false
431
+ ```
432
+
433
+ ### `Syntax Error: Document is nested more than 1000 levels deep. Parsing aborted.`
434
+
435
+ **When:** a query is answered with `GRAPHQL_PARSE_FAILED` (400 under
436
+ `application/graphql-response+json`, 200 under `application/json`) and this
437
+ message. A document that overflowed the stack anyway has
438
+ [its own entry](#syntax-error-document-is-nested-too-deeply-to-parse).
439
+
440
+ **Why:** a document may nest 1 000 levels of `{`, `(` and `[` by default
441
+ (`limits.nesting`). graphql-js parses by recursion and overflows the stack a few
442
+ thousand levels down, under `limits.tokens`; without the limit that was a 500
443
+ `Unexpected error.`, logged. A real query nests a dozen levels, so this is
444
+ a hostile or generated document.
445
+
446
+ **Fix:** if a generated query really nests deeper, raise the limit, within
447
+ what your runtime's stack parses (several thousand levels: about 10 000 on
448
+ Bun's main thread, fewer in a Worker), or turn it off:
449
+
450
+ ```ts
451
+ graphql(app, { schema, limits: { nesting: 2_000 } }); // or false
452
+ ```
453
+
454
+ ### `Syntax Error: Document is nested too deeply to parse.`
455
+
456
+ **When:** a query is answered with `GRAPHQL_PARSE_FAILED` and this message.
457
+
458
+ **Why:** graphql-js parsed the document by recursion and the call stack
459
+ overflowed, either because `limits.nesting` is `false` or raised past what the
460
+ runtime parses. The stack is smaller in a Worker or under load than on Bun's
461
+ main thread, so the depth that fails varies. The overflow is refused as any
462
+ unparsable document is, never a 500.
463
+
464
+ **Fix:** a real query nests a dozen levels; look for a hostile or generated
465
+ document. If it is legitimate, keep the limit (the default is 1 000) or set
466
+ one your runtime parses:
467
+
468
+ ```ts
469
+ graphql(app, { schema, limits: { nesting: 500 } });
470
+ ```
471
+
472
+ ### `200 {"errors":[{"message":"Unexpected error.", … "code":"INTERNAL_SERVER_ERROR"}}]}`
473
+
474
+ **When:** a resolver throws an `Error`, or rejects.
475
+
476
+ **Why:** graxia masks errors by default, so a database message or a stack
477
+ never reaches a client. The error carries a correlation id in
478
+ `extensions.reference`; the original goes to `onUnexpected` (`console.error`
479
+ by default, off in production).
480
+
481
+ **Fix:** throw `exposedError(code, message)` for what the client should read; it passes
482
+ unmasked, with its code
483
+ ([Errors](guide/plugins.md#errors)):
484
+
485
+ ```ts
486
+ import { exposedError } from '@softistx/graxia';
487
+
488
+ throw exposedError('FORBIDDEN', 'Admins only');
489
+ ```
490
+
491
+ `maskErrors: false` (or the deprecated `maskedErrors`) shows every message, for development only.
492
+
493
+ ### `413 … "code":"BODY_TOO_LARGE"` on `POST /graphql`
494
+
495
+ **When:** the body of a `POST` is larger than its limit, with a
496
+ `Content-Length` or chunked. The limit is **1 MiB** unless the `bodyLimit`
497
+ option or a `bodyLimit()` declared before `graphql(...)` gives another.
498
+
499
+ **Why:** the limit is graxia's `limits.bodyBytes`: graxia refuses a declared
500
+ size at once and counts the stream otherwise, and the answer is
501
+ `{"errors":[{"message":"The request body is too large.","extensions":{"code":"BODY_TOO_LARGE","fix":"…"}}]}`
502
+ in graxia's JSON format, whatever the app's `errors` option is, with the
503
+ headers the plugins set. Core's own `bodyLimit()` counter does not run on the
504
+ endpoint (it would make a chunked body past the limit an unreadable `400`).
505
+ Core's counter being off, the middlewares declared after `bodyLimit()` run for an oversized body before graxia answers the 413. Nothing is logged, whatever the content type.
506
+
507
+ **Fix:** a client sends less, or the endpoint takes a larger limit, for an
508
+ upload by `multipart` for example:
509
+
510
+ ```ts
511
+ graphql(app, { schema, bodyLimit: 5 * 1024 * 1024 });
512
+ ```
513
+
514
+ A client matches `errors[0].extensions.code`, never the message.
515
+
516
+ ### `415 … "code":"UNSUPPORTED_MEDIA_TYPE"`
517
+
518
+ **When:** a `POST` whose `Content-Type` is not `application/json` (UTF-8): a
519
+ form (`application/x-www-form-urlencoded`), `application/graphql`, none at all.
520
+
521
+ **Why:** graxia reads JSON bodies only and refuses the other types before it
522
+ reads the body, whatever its size, so such a body past the limit is a 415, not
523
+ a 413.
524
+
525
+ **Fix:** send `Content-Type: application/json` with `{"query": …}`. For a file
526
+ upload, enable graxia's `uploads` and send `multipart/form-data`.
527
+
528
+ ### `403 CSRF_HEADER_REQUIRED` from the test client
529
+
530
+ **When:** `graphqlClient(app, { csrfHeader: false })`, or an app whose
531
+ `csrf.requireHeader` lists a header other than `x-graphql-csrf`, answers a
532
+ `GET` with a 403.
533
+
534
+ **Why:** the client sends `x-graphql-csrf` on a `GET` by default. An app
535
+ that replaced the list does not accept it, and `false` sends none.
536
+
537
+ **Fix:** name the app's header:
538
+
539
+ ```ts
540
+ graphqlClient(app, { csrfHeader: 'x-my-app' });
541
+ ```
542
+
543
+ ### `PersistedQueryNotFound` or `PersistedQueryNotSupported`
544
+
545
+ **When:** a request that sends a persisted-query hash is answered
546
+ `PersistedQueryNotFound` (`PERSISTED_QUERY_NOT_FOUND`: the hash is unknown and
547
+ no query text came with it) or `PersistedQueryNotSupported`
548
+ (`PERSISTED_QUERY_NOT_SUPPORTED`: `trustedDocuments.apq` is off). Related
549
+ refusals on the same path: `provided sha does not match query`
550
+ (`PROVIDED_SHA_DOESNT_MATCH`), `Persisted document <id> not found.` for a
551
+ `documentId` the manifest lacks (`PERSISTED_QUERY_NOT_FOUND`) and, in `strict`
552
+ mode, `Only persisted documents are allowed.` (`PERSISTED_QUERY_ONLY`) for a
553
+ plain document.
554
+
555
+ **Why:** graxia's `trustedDocuments` does not know the hash, and has no
556
+ automatic persisted queries to learn it from.
557
+
558
+ **Fix:** send the request again with the query text beside the hash (when
559
+ `apq` is on, the server stores it), put the document in the trusted manifest
560
+ and send its `documentId`, or turn `apq` on. For a plain document in `strict`
561
+ mode, send a `documentId`, or set `trustedDocuments.mode` to `"mixed"`.
562
+
563
+ ### `405 {"error":"method_not_allowed"}` on `OPTIONS /graphql`
564
+
565
+ **When:** a browser on another origin calls the endpoint; its preflight
566
+ fails and the console reports a CORS error.
567
+
568
+ **Why:** graxia has no CORS, and the app answers no `OPTIONS` without a
569
+ CORS middleware.
570
+
571
+ **Fix:** `@softistx/alxia-cors`, given to `use` first, for the whole app: it answers a
572
+ preflight itself, before the router's 404 or 405 ([CORS](guide/plugins.md#cors)):
573
+
574
+ ```ts
575
+ import { cors } from '@softistx/alxia-cors';
576
+
577
+ const app = alxia()
578
+ .use(cors({ origin: 'https://app.example.com', credentials: true }))
579
+ .plugin((app) => graphql(app, { schema }));
580
+ ```
581
+
582
+ ### `405 {"errors":[{"message":"Can only perform a mutation operation from a POST request."}]}`
583
+
584
+ **When:** a mutation sent as `GET /graphql?query=mutation …`. The body also
585
+ carries `"extensions":{"code":"METHOD_NOT_ALLOWED"}`.
586
+
587
+ **Why:** graxia refuses mutations over `GET` (`METHOD_NOT_ALLOWED`), which a link or a cache could
588
+ replay.
589
+
590
+ **Fix:** send it as a `POST`:
591
+
592
+ ```ts
593
+ await fetch('/graphql', {
594
+ method: 'POST',
595
+ headers: { 'content-type': 'application/json' },
596
+ body: JSON.stringify({ query: 'mutation { login(name: "ada") }' }),
597
+ });
598
+ ```
599
+
600
+ ### `406` with an empty body
601
+
602
+ **When:** a subscription sent with `Accept: application/json`; or a
603
+ request whose `Accept` allows only `text/html` (no `*/*`, no
604
+ `application/json`), such as `curl -H 'accept: text/html'`, where no IDE
605
+ page is served — `ide: false`, or `ide: 'apollo-sandbox'` with a `?query=`
606
+ in the URL. A browser sends `*/*` too, and gets JSON there.
607
+
608
+ **Why:** a subscription is a stream of results: graxia sends it only to a
609
+ client that accepts `text/event-stream`, and has no other representation
610
+ to offer. Likewise, a result has no HTML representation: a client asking
611
+ only for HTML, with no IDE page to serve it, gets nothing it accepts.
612
+
613
+ **Fix:** for a subscription, accept `text/event-stream`:
614
+
615
+ ```ts
616
+ await fetch('/graphql', {
617
+ method: 'POST',
618
+ headers: { 'content-type': 'application/json', accept: 'text/event-stream' },
619
+ body: JSON.stringify({ query: 'subscription { countdown(from: 3) }' }),
620
+ });
621
+ ```
622
+
623
+ For a client that asks only for HTML, accept `application/json` (or
624
+ `*/*`) where no IDE is served, or keep an IDE where one is wanted — see
625
+ [GraphiQL and Apollo Sandbox](guide/ide.md).
626
+
627
+ ### `{"errors":[{"message":"Must provide a query string."}]}`
628
+
629
+ **When:** a `GET` with no `query` parameter from a client that does not ask
630
+ for HTML — or from a browser when `ide` is `false` — or a `POST` whose JSON
631
+ body has no `query`. The body carries
632
+ `"extensions":{"code":"QUERY_REQUIRED"}` (400).
633
+
634
+ **Why:** the request reached graxia, with nothing to run. A `GET` from a
635
+ browser gets the IDE page instead, unless `ide` is `false`; a client
636
+ asking only for HTML gets a [`406`](#406-with-an-empty-body) where no page is
637
+ served.
638
+
639
+ **Fix:** send the operation as `query`, in the body or the URL:
640
+
641
+ ```ts
642
+ await app.request(`/graphql?query=${encodeURIComponent('{ me }')}`, {
643
+ headers: { accept: 'application/json' },
644
+ });
645
+ ```
646
+
647
+ ### A WebSocket closes with 4400 after the first message
648
+
649
+ **When:** a client sends `connection_init` or any message as a **binary** frame
650
+ (a `Uint8Array`, a `Blob`); the socket closes at once with code `4400`.
651
+
652
+ **Why:** graxia refuses binary frames: `graphql-transport-ws` messages are JSON
653
+ text. Yoga's `graphql-ws` decoded a binary frame; graxia does not.
654
+
655
+ **Fix:** send the message as a text frame: `socket.send(JSON.stringify(message))`.
656
+ `graphql-ws`'s `createClient` already does.
657
+
658
+ ### `The Sec-WebSocket-Protocol header must offer "graphql-transport-ws".` (400, `SUBPROTOCOL_REQUIRED`)
659
+
660
+ **When:** a socket opens on an endpoint with `ws` on and the upgrade is
661
+ refused with a plain HTTP `400` and this code, before any socket exists.
662
+
663
+ **Why:** the client offered no subprotocol, or only one the endpoint does
664
+ not serve. `ws` serves `graphql-transport-ws`, the protocol of
665
+ `graphql-ws`; the legacy `subscriptions-transport-ws` client
666
+ offers `graphql-ws`, its own, older protocol, and a bare `new WebSocket(url)`
667
+ offers none.
668
+
669
+ **Fix:** connect with `graphql-ws`'s `createClient`, or with a client built
670
+ on it (Apollo Client's `GraphQLWsLink` from
671
+ `@apollo/client/link/subscriptions`, urql's `subscriptionExchange` given a
672
+ `graphql-ws` client). A hand-written socket names the protocol:
673
+
674
+ ```ts
675
+ const socket = new WebSocket('ws://localhost:3000/graphql', 'graphql-transport-ws');
676
+ ```
677
+
678
+ ## Traps
679
+
680
+ ### The endpoint answers without a guard declared after it
681
+
682
+ **When:** `.plugin((app) => graphql(app, { schema }))` comes before
683
+ `.use(bearer(…))` or a guarding `derive`: the endpoint answers anonymous
684
+ requests, and its resolvers read no `user`.
685
+
686
+ **Why:** a middleware applies to the routes declared after it. The endpoint
687
+ is a route, declared where `graphql` is called, so a middleware given to `use`
688
+ after it never runs for it. A schema typed from the
689
+ guarded app is refused (`missing user`); an untyped one is not.
690
+
691
+ **Fix:** declare the guard first:
692
+
693
+ ```ts
694
+ const base = alxia().use(bearer({ jwt }));
695
+ const app = base.plugin((app) => graphql(app, { schema }));
696
+ ```
697
+
698
+ ### Every log line and span is an anonymous `POST /graphql`
699
+
700
+ **When:** `@softistx/alxia-logger` writes `POST /graphql 200` with no
701
+ `operationName`, and the span of `@softistx/alxia-telemetry` is named
702
+ `POST /graphql`.
703
+
704
+ **Why:** an operation is reported only when graxia executes it (graxia's own operation span is off, and its parse, validate and execute spans nest under `@softistx/alxia-telemetry`'s span). A request
705
+ refused before that (a syntax error, a document that fails validation) names
706
+ none; an operation over `ws: true` is a line and a span of its own, not
707
+ the upgrade's ([the WebSocket guide](guide/websockets.md#logging-and-tracing));
708
+ and a logger or a
709
+ telemetry given to `use` *after* the endpoint, or a version of
710
+ `@softistx/alxia` older than the one that reports (`operationOf`), never reads
711
+ it.
712
+
713
+ **Fix:** give `logger()` and `telemetry()` to `use` before `graphql()`, and
714
+ update `@softistx/alxia`, `@softistx/alxia-graphql`, `@softistx/alxia-logger` and
715
+ `@softistx/alxia-telemetry` together. See
716
+ [the endpoint guide](guide/endpoint.md#the-operation-in-the-log-and-the-trace).
717
+
718
+ ### graxia's parse, validate or resolver spans are missing
719
+
720
+ **When:** `@softistx/alxia-telemetry` shows the operation's span but none of graxia's
721
+ `graphql.parse`, `graphql.validate` or resolver spans, or no host span is
722
+ active when the request arrives.
723
+
724
+ **Why:** `graphql()` sets graxia's `telemetry` to `{ operationSpans: false }`,
725
+ which keeps the parse, validate and execute spans but not the resolver spans
726
+ (a resolver span per field is opt-in), and they exist only under an active
727
+ span: with no `@softistx/alxia-telemetry` in front of the endpoint there is no host
728
+ span, and graxia makes its own request and operation spans instead. If you
729
+ passed `telemetry: false`, graxia makes none at all.
730
+
731
+ **Fix:** put `use(telemetry({ … }))` before `graphql()`, pass
732
+ `telemetry: { resolverSpans: true }` for resolver spans (the
733
+ `operationSpans: false` default stays under an object you pass; set
734
+ `operationSpans: true` yourself to bring graxia's operation span back), and
735
+ leave `telemetry: false` out. See
736
+ [graxia's own spans](guide/endpoint.md#graxias-own-spans).
737
+
738
+ ### The logger, CORS or secure headers miss the endpoint
739
+
740
+ **When:** `use(logger())`, `use(cors(…))` or `use(secureHeaders())` comes
741
+ after `.plugin((app) => graphql(app, { schema }))`: the endpoint is not
742
+ logged, its responses carry no CORS or security headers.
743
+
744
+ **Why:** a `use` middleware runs on the routes declared after it, and on a
745
+ request no route matches. The endpoint is declared before it.
746
+
747
+ **Fix:** give the observers to `use` first:
748
+
749
+ ```ts
750
+ const app = alxia()
751
+ .use(logger())
752
+ .use(cors({ origin: 'https://app.example.com' }))
753
+ .plugin((app) => graphql(app, { schema }));
754
+ ```
755
+
756
+ ### An anonymous request to a missing path is a 401
757
+
758
+ **When:** `use(bearer(…))` is on the app, and `GET /nope` answers
759
+ `401` rather than `404`.
760
+
761
+ **Why:** a guard given to the app's `use` runs on every request, a request
762
+ no route matches included, and answers before the 404.
763
+
764
+ **Fix:** scope the guard to what it guards, with a `group`. A path-scoped
765
+ `use('/graphql', bearer(…))` does not compile: a middleware given a path may
766
+ add nothing to the context, and `bearer` adds `user`.
767
+
768
+ ```ts
769
+ const app = alxia()
770
+ .get('/health', ({ reply }) => reply(200, 'ok'))
771
+ .group('/api', (api) =>
772
+ api
773
+ .use(bearer({ jwt }))
774
+ .plugin((app) => graphql(app, { schema })), // /api/graphql: a 401 without a token
775
+ );
776
+ // GET /nope → 404, GET /api/nope → 404
777
+ ```
778
+
779
+ ### A WebSocket client cannot connect: `Expected 101 status code`
780
+
781
+ **When:** a `graphql-ws` client — Apollo Client's `GraphQLWsLink`, urql's
782
+ `subscriptionExchange`, GraphiQL with `subscriptionsProtocol: 'WS'` — opens
783
+ `ws://…/graphql`. Bun's client prints `Expected 101 status code`; a browser
784
+ reports the WebSocket connection as failed.
785
+
786
+ **Why:** `ws` is off, the default: the endpoint serves subscriptions over
787
+ server-sent events, and never upgrades to a WebSocket. With `ws` on, the
788
+ same message means the upgrade was answered otherwise: a guard's `401`, a
789
+ `500` naming a missing `ws` runtime,
790
+ or a socket `path` other than the one the client opens.
791
+
792
+ **Fix:** serve WebSocket too ([GraphQL over WebSocket](guide/websockets.md)):
793
+
794
+ ```ts
795
+ graphql(app, { schema, ws: true });
796
+ ```
797
+
798
+ Or leave `ws` off, and subscribe over SSE, with `Accept: text/event-stream`
799
+ ([Subscriptions](guide/plugins.md#subscriptions)), GraphiQL's protocol left at
800
+ SSE:
801
+
802
+ ```ts
803
+ graphql(app, { schema, graphiql: { subscriptionsProtocol: 'SSE' } });
804
+ ```
805
+
806
+ ### Every WebSocket operation is refused by a client-header check
807
+
808
+ **When:** an `onParams` plugin refuses a request without a client header
809
+ (`x-client`, an API key), HTTP works, and every operation over the WebSocket is
810
+ refused although the connection is acknowledged.
811
+
812
+ **Why:** `onParams` runs for each WebSocket operation too, and a browser's
813
+ upgrade request carries no custom header.
814
+
815
+ **Fix:** skip the socket operations with `connectionParams`, which `onParams`
816
+ receives only for an operation over a WebSocket (needs `@softistx/graxia` 0.14 or later).
817
+ Authenticate the socket in the `context` option instead: read
818
+ `init.connectionParams` and throw when it is missing or wrong.
819
+
820
+ ```ts
821
+ // file: src/require-client-header.ts
822
+ import { definePlugin } from '@softistx/graxia';
823
+
824
+ export const requireClientHeader = definePlugin()({
825
+ name: 'require-client-header',
826
+ onParams: ({ request, connectionParams, respond }) => {
827
+ if (connectionParams) return; // a socket operation
828
+ if (!request.headers.get('x-client'))
829
+ respond(new Response('Missing x-client', { status: 400 }));
830
+ },
831
+ });
832
+ ```
833
+
834
+ Never test the `Upgrade` header to tell a socket from HTTP: over HTTP it can be forged.
835
+ A socket opened with no payload is not skipped either: refuse it in the
836
+ `context` option (`if (!connectionParams) throw …`) or with an upgrade guard
837
+ ([upgrade middlewares](guide/websockets.md#the-upgrade-runs-the-apps-middlewares)).
838
+
839
+ ### An idle subscription over SSE is reset after about 10 seconds
840
+
841
+ **When:** a subscription over server-sent events that has nothing to send
842
+ for a few seconds, on a real server: the client sees the connection reset at
843
+ 8 to 10 seconds, before any event. A spec using `app.request` never shows it.
844
+
845
+ **Why:** graxia pings an open stream every 12 seconds, but `Bun.serve` closes a
846
+ connection idle for `idleTimeout` seconds, 10 by default, before the first
847
+ ping. `server.timeout(request, 0)` called from a resolver does not change it
848
+ for the stream.
849
+
850
+ **Fix:** set `idleTimeout` above the ping interval in `listen`'s options:
851
+
852
+ ```ts
853
+ app.listen({ port: 3000, idleTimeout: 30 });
854
+ ```
855
+
856
+ The same holds behind a proxy or load balancer: its read timeout must be
857
+ longer than the ping. For a React Router app, see
858
+ [Subscriptions for a BFF](../../react-router/docs/guide/subscriptions.md#keep-the-stream-alive).
859
+
860
+ ### A subscription is dropped after a while, or outlives a revoked session
861
+
862
+ **When:** an SSE subscription stays open for hours after the client stopped
863
+ reading, or keeps delivering after the viewer's session ended.
864
+
865
+ **Why:** an async iterable returned by `subscribe` has no bound of its own,
866
+ and a check done once at connection is never repeated.
867
+
868
+ **Fix:** wrap the source in `boundedStream` with `idleMs`, `totalMs` and a
869
+ `check` ([guide](guide/plugins.md#bound-a-subscription)). A stream that ends at
870
+ `idleMs` while pings still flow is expected: pings are not events of the
871
+ source.
872
+
873
+ ```ts
874
+ declare const source: AsyncIterable<unknown>;
875
+ declare function check(): Promise<void>;
876
+
877
+ subscribe: () => boundedStream(source, { idleMs: 90_000, totalMs: 600_000, checkEveryMs: 30_000, check })
878
+ ```
879
+
880
+ ### unmet peer `@softistx/graxia` from `@softistx/graxia-graphiql`
881
+
882
+ **When:** `bun install` warns that `@softistx/graxia-graphiql` wants a `@softistx/graxia`
883
+ other than the one installed, or the install holds two copies of core.
884
+
885
+ **Why:** each `@softistx/graxia-graphiql` release peers on exactly one core minor
886
+ (0.4.0 on core 0.16; under the former `@graxia/*` names, 0.2.4 on core 0.10 up
887
+ to 0.2.8 on 0.14).
888
+
889
+ **Fix:** install the graphiql that matches your core, for example
890
+ `bun add @softistx/graxia-graphiql@^0.4.0` with `@softistx/graxia` 0.16.
891
+
892
+ ### The IDE page is blank
893
+
894
+ **When:** GraphiQL or Apollo Sandbox loads an empty page, and the browser
895
+ console reports scripts refused by the `Content-Security-Policy`.
896
+
897
+ **Why:** the endpoint sends the IDE with a policy that lets it load its
898
+ scripts from `unpkg.com` or Apollo's CDN. A middleware of the app that sets its
899
+ own `Content-Security-Policy` on every response replaces it.
900
+ `@softistx/alxia-secure-headers` does not: it keeps a policy a response already has.
901
+
902
+ **Fix:** set the app's policy only where none is set
903
+ ([With `@softistx/alxia-secure-headers`](guide/ide.md#with-softistxalxia-secure-headers)):
904
+
905
+ ```ts
906
+ const defaultPolicy = defineMiddleware(async (ctx, next) =>
907
+ withHeaders(await settle(ctx, next()), (headers) => {
908
+ if (!headers.has('content-security-policy'))
909
+ headers.set('content-security-policy', "default-src 'self'");
910
+ }),
911
+ );
912
+
913
+ app.use(defaultPolicy); // before the endpoint, so it wraps it
914
+ ```
915
+
916
+ ### The heap grows with distinct queries
917
+
918
+ **When:** a server that receives many different large queries, such as
919
+ generated ones or ones built with inline values, holds more and more memory.
920
+
921
+ **Why:** graxia keeps parsed documents in a cache bounded by the number of
922
+ entries (`caches.parse.max`, 1 024 by default) and their age (`ttlMs`), not by
923
+ their size: a few thousand distinct large documents hold a lot of memory.
924
+
925
+ **Fix:** lower `caches.parse.max`, send variables instead of inline values so
926
+ the documents repeat, or turn the cache off:
927
+
928
+ ```ts
929
+ graphql(app, { schema, caches: { parse: { max: 256, ttlMs: 10 * 60_000 } } }); // or caches: false
930
+ ```
931
+
932
+ ### GraphiQL is served in production
933
+
934
+ **When:** a browser opening the production endpoint gets GraphiQL.
935
+
936
+ **Why:** the app gives `ide: 'graphiql'`, which serves it in every mode, or
937
+ the serving app is in dev there (`NODE_ENV=development`, or
938
+ `alxia({ dev: true })`). Without `ide`, GraphiQL follows the dev switch
939
+ since 0.5; before, it was on everywhere.
940
+
941
+ **Fix:** leave `ide` out, and keep `NODE_ENV=development` out of the
942
+ deployed environment, or turn it off:
943
+
944
+ ```ts
945
+ graphql(app, { schema, ide: false });
946
+ ```
947
+
948
+ ### GraphiQL does not open in development, or in a test
949
+
950
+ **When:** a browser's `GET` at the endpoint gets a JSON result, or
951
+ `Must provide a query string.`, where GraphiQL used to open.
952
+
953
+ **Why:** without `ide`, GraphiQL is served in the serving app's dev alone:
954
+ `alxia({ dev })`, else `NODE_ENV=development`. An explicit `dev: false`
955
+ turns it off even under `NODE_ENV=development`, and `bun test` sets
956
+ `NODE_ENV=test`.
957
+
958
+ **Fix:** run the `dev` script with `NODE_ENV=development` (or give
959
+ `alxia({ dev: true })`), or give the IDE explicitly where it must open:
960
+
961
+ ```ts
962
+ graphql(app, { schema, ide: 'graphiql' });
963
+ ```