@alxia/graphql 0.18.1 → 0.18.3
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 +1 -1
- package/dist/index.js +58 -3
- package/dist/index.js.map +3 -3
- package/dist/operation.d.ts +1 -1
- package/dist/operation.d.ts.map +1 -1
- package/docs/guide/websockets.md +6 -1
- package/docs/migrating-to-graxia.md +79 -11
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ bun add -d typescript
|
|
|
13
13
|
bun add @graxia/envelop @envelop/depth-limit # install yourself to use Envelop plugins
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
`@graxia/core` (`^0.10.0 || ^0.11.0`), `@graxia/graphiql` (`^0.2.4`) and `graphql` (17.1 or later) are peers:
|
|
16
|
+
`@graxia/core` (`^0.10.0 || ^0.11.0 || ^0.12.0`), `@graxia/graphiql` (`^0.2.4`) and `graphql` (17.1 or later) are peers:
|
|
17
17
|
the package declares no dependency. `@graxia/graphiql` serves the IDE and is
|
|
18
18
|
required. CSRF protection is graxia's default (on): a `GET` needs one of the
|
|
19
19
|
`x-graphql-csrf`, `graphql-require-preflight`, `apollo-require-preflight` or
|
package/dist/index.js
CHANGED
|
@@ -154,7 +154,9 @@ import {
|
|
|
154
154
|
startOperation
|
|
155
155
|
} from "@alxia/core";
|
|
156
156
|
import { createStateKey, definePlugin } from "@graxia/core";
|
|
157
|
-
import {
|
|
157
|
+
import {
|
|
158
|
+
getOperationAST
|
|
159
|
+
} from "graphql";
|
|
158
160
|
var nameKey = createStateKey("alxia-operation-name");
|
|
159
161
|
var openKey = createStateKey("alxia-operation-open");
|
|
160
162
|
function describe(document, name) {
|
|
@@ -164,6 +166,44 @@ function describe(document, name) {
|
|
|
164
166
|
return { type: operation.operation, name: operation.name?.value };
|
|
165
167
|
}
|
|
166
168
|
var isStream = (result) => typeof result === "object" && result !== null && (Symbol.asyncIterator in result);
|
|
169
|
+
var isIncremental = (result) => typeof result === "object" && result !== null && ("initialResult" in result) && typeof result.subsequentResults?.next === "function";
|
|
170
|
+
var carriesErrors = (chunk) => {
|
|
171
|
+
if (typeof chunk !== "object" || chunk === null)
|
|
172
|
+
return false;
|
|
173
|
+
const payload = chunk;
|
|
174
|
+
if (Array.isArray(payload.errors) && payload.errors.length > 0)
|
|
175
|
+
return true;
|
|
176
|
+
return [payload.incremental, payload.completed].some((entries) => Array.isArray(entries) && entries.some((entry) => typeof entry === "object" && entry !== null && Array.isArray(entry.errors) && entry.errors.length > 0));
|
|
177
|
+
};
|
|
178
|
+
function observed(chunks, progress, end) {
|
|
179
|
+
const wrapped = {
|
|
180
|
+
async next() {
|
|
181
|
+
try {
|
|
182
|
+
const step = await chunks.next();
|
|
183
|
+
if (step.done === true)
|
|
184
|
+
end(progress.outcome);
|
|
185
|
+
else if (carriesErrors(step.value))
|
|
186
|
+
progress.outcome = "errors";
|
|
187
|
+
return step;
|
|
188
|
+
} catch (error) {
|
|
189
|
+
progress.outcome = "errors";
|
|
190
|
+
end("errors");
|
|
191
|
+
throw error;
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
return(value) {
|
|
195
|
+
end(progress.outcome);
|
|
196
|
+
return chunks.return(value);
|
|
197
|
+
},
|
|
198
|
+
throw(error) {
|
|
199
|
+
return chunks.throw(error);
|
|
200
|
+
},
|
|
201
|
+
[Symbol.asyncIterator]() {
|
|
202
|
+
return wrapped;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
return wrapped;
|
|
206
|
+
}
|
|
167
207
|
var failed = (result) => typeof result === "object" && result !== null && ("errors" in result) ? "errors" : "ok";
|
|
168
208
|
function reportsOperations() {
|
|
169
209
|
return definePlugin({
|
|
@@ -187,7 +227,22 @@ function reportsOperations() {
|
|
|
187
227
|
return;
|
|
188
228
|
reportOperation(contextValue, report);
|
|
189
229
|
const end = startOperation(contextValue, report);
|
|
190
|
-
return ({ result }) =>
|
|
230
|
+
return ({ result, setResult }) => {
|
|
231
|
+
if (!isIncremental(result))
|
|
232
|
+
return end(failed(result));
|
|
233
|
+
const progress = {
|
|
234
|
+
outcome: carriesErrors(result.initialResult) ? "errors" : "ok"
|
|
235
|
+
};
|
|
236
|
+
const signal = contextValue.signal;
|
|
237
|
+
const onAbort = () => finish(progress.outcome);
|
|
238
|
+
const finish = (outcome) => {
|
|
239
|
+
signal?.removeEventListener("abort", onAbort);
|
|
240
|
+
end(outcome);
|
|
241
|
+
};
|
|
242
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
243
|
+
const subsequentResults = observed(result.subsequentResults, progress, finish);
|
|
244
|
+
setResult({ ...result, subsequentResults });
|
|
245
|
+
};
|
|
191
246
|
},
|
|
192
247
|
onSubscribe: ({ args, state }) => {
|
|
193
248
|
const { document, operationName, contextValue } = args;
|
|
@@ -562,5 +617,5 @@ export {
|
|
|
562
617
|
oncePerRequest
|
|
563
618
|
};
|
|
564
619
|
|
|
565
|
-
//# debugId=
|
|
620
|
+
//# debugId=30AF2FD9C538C31F64756E2164756E21
|
|
566
621
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"/** What bounds a stream, and what keeps it authorized. All durations in ms. */\nexport interface BoundedStreamOptions {\n\t/** The stream ends, cleanly, after this long without an event. */\n\tidleMs: number;\n\t/** The stream ends, cleanly, this long after it began, however chatty. */\n\ttotalMs: number;\n\t/** `check` runs at least this often, also while no event comes. */\n\tcheckEveryMs: number;\n\t/**\n\t * Before an event is yielded, `check` runs when the last check is at least\n\t * this old. Default `0`: every event is checked. Raise it when events come\n\t * in bursts and one check per event would cost more than the delay of a\n\t * revocation it saves.\n\t */\n\tcheckDebounceMs?: number;\n\t/** Throws to refuse (a session that ended, a role that was lost). */\n\tcheck: () => Promise<void> | void;\n\t/** Turns what `check` (or the source) threw into the error the stream throws. Default: rethrown as is. */\n\tmapError?: (error: unknown) => unknown;\n\t/** Aborted when the client leaves: the stream ends and releases the source. */\n\tsignal?: AbortSignal;\n}\n\ntype Woke<T> =\n\t| { kind: 'read'; result: IteratorResult<T> }\n\t| { kind: 'failed'; error: unknown }\n\t| { kind: 'timer' }\n\t| { kind: 'interrupted' };\n\nconst DONE = { done: true, value: undefined } as const;\n\n/**\n * `source` bounded by an idle and a total lifetime and re-checked while it\n * lives, to return as a subscription's `subscribe` result.\n *\n * It ends, without an error, when the source ends, on the idle bound, on the\n * total bound and on `signal`'s abort. It throws `mapError(error)` (the\n * error itself by default) when `check` fails, or when the source does. The\n * source's `return()` is called at once on the consumer's `return()` (a\n * client that disconnected) and on any end, even while a read is pending: the\n * iterator is written by hand because a generator's `return()` waits behind a\n * pending `next()`. Read it one `next()` at a time, as `for await` does. No\n * timer outlives a step.\n */\nexport function boundedStream<T>(\n\tsource: AsyncIterable<T> | AsyncIterator<T>,\n\toptions: BoundedStreamOptions,\n): AsyncIterableIterator<T> {\n\tconst { idleMs, totalMs, checkEveryMs, check, signal } = options;\n\tconst debounceMs = options.checkDebounceMs ?? 0;\n\tconst mapError = options.mapError ?? ((error: unknown) => error);\n\tconst iterator: AsyncIterator<T> =\n\t\tSymbol.asyncIterator in source\n\t\t\t? (source as AsyncIterable<T>)[Symbol.asyncIterator]()\n\t\t\t: (source as AsyncIterator<T>);\n\n\tconst startedAt = Date.now();\n\tlet lastEventAt = startedAt;\n\tlet lastCheckAt = startedAt;\n\tlet finished = false;\n\tlet interrupt: (() => void) | undefined;\n\tlet pending: Promise<IteratorResult<T>> | undefined;\n\tlet released: Promise<void> | undefined;\n\n\tconst release = (): Promise<void> => {\n\t\tfinished = true;\n\t\tinterrupt?.();\n\t\treleased ??= (async () => {\n\t\t\ttry {\n\t\t\t\tawait iterator.return?.(undefined);\n\t\t\t} catch {}\n\t\t})();\n\t\treturn released;\n\t};\n\n\tconst onAbort = () => void release();\n\tif (signal?.aborted) void release();\n\telse signal?.addEventListener('abort', onAbort, { once: true });\n\tconst detach = () => signal?.removeEventListener('abort', onAbort);\n\n\tconst checked = async () => {\n\t\tawait check();\n\t\tlastCheckAt = Date.now();\n\t};\n\n\t// Waits for the source, the nearest bound or the abort, whichever is first.\n\tconst wait = (read: Promise<IteratorResult<T>>, ms: number) =>\n\t\tnew Promise<Woke<T>>((resolve) => {\n\t\t\tconst settle = (woke: Woke<T>) => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tinterrupt = undefined;\n\t\t\t\tresolve(woke);\n\t\t\t};\n\t\t\tconst timer = setTimeout(() => settle({ kind: 'timer' }), ms);\n\t\t\tinterrupt = () => settle({ kind: 'interrupted' });\n\t\t\tread.then(\n\t\t\t\t(result) => settle({ kind: 'read', result }),\n\t\t\t\t(error: unknown) => settle({ kind: 'failed', error }),\n\t\t\t);\n\t\t});\n\n\tconst step = async (): Promise<IteratorResult<T>> => {\n\t\tfor (;;) {\n\t\t\tif (finished) return DONE;\n\t\t\tconst t = Date.now();\n\t\t\tconst left = [totalMs - (t - startedAt), idleMs - (t - lastEventAt)];\n\t\t\tif (Math.min(...left) <= 0) {\n\t\t\t\tawait release();\n\t\t\t\treturn DONE;\n\t\t\t}\n\t\t\tconst dueIn = checkEveryMs - (t - lastCheckAt);\n\t\t\tif (dueIn <= 0) {\n\t\t\t\tawait checked();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!pending) {\n\t\t\t\tpending = iterator.next();\n\t\t\t\tpending.catch(() => {});\n\t\t\t}\n\t\t\tconst woke = await wait(pending, Math.max(1, Math.min(dueIn, ...left)));\n\t\t\tif (woke.kind === 'interrupted') {\n\t\t\t\tawait release();\n\t\t\t\treturn DONE;\n\t\t\t}\n\t\t\tif (woke.kind === 'timer') continue;\n\t\t\tpending = undefined;\n\t\t\tif (woke.kind === 'failed') throw woke.error;\n\t\t\tif (woke.result.done) {\n\t\t\t\tawait release();\n\t\t\t\treturn DONE;\n\t\t\t}\n\t\t\tlastEventAt = Date.now();\n\t\t\tif (lastEventAt - lastCheckAt >= debounceMs) await checked();\n\t\t\tif (finished) return DONE;\n\t\t\treturn { done: false, value: woke.result.value };\n\t\t}\n\t};\n\n\tconst stream: AsyncIterableIterator<T> = {\n\t\t[Symbol.asyncIterator]: () => stream,\n\t\tnext: async () => {\n\t\t\ttry {\n\t\t\t\tconst result = await step();\n\t\t\t\tif (result.done) detach();\n\t\t\t\treturn result;\n\t\t\t} catch (error) {\n\t\t\t\tawait release();\n\t\t\t\tdetach();\n\t\t\t\tthrow mapError(error);\n\t\t\t}\n\t\t},\n\t\treturn: async () => {\n\t\t\tawait release();\n\t\t\tdetach();\n\t\t\treturn DONE;\n\t\t},\n\t};\n\treturn stream;\n}\n",
|
|
7
7
|
"import type { Empty } from '@alxia/core';\nimport { createGraxia, type GraxiaOptions } from '@graxia/core';\nimport type { GraphQLSchema } from 'graphql';\nimport { graxiaOptions, type LegacyOptions } from './options';\n\n/** What an in-process call asks for: a GraphQL-over-HTTP request's parameters. */\nexport interface ExecutorRequest {\n\treadonly query: string;\n\treadonly operationName?: string | undefined;\n\treadonly variables?: Readonly<Record<string, unknown>> | undefined;\n}\n\n/** A plain, JSON-shaped error, as the route answers it. */\nexport interface ExecutorError {\n\treadonly message: string;\n\treadonly path?: readonly (string | number)[];\n\treadonly locations?: readonly { line: number; column: number }[];\n\treadonly extensions?: Readonly<Record<string, unknown>>;\n}\n\n/** The answer: `data` and `errors`, as the endpoint's JSON body. */\nexport interface ExecutorResult {\n\treadonly data?: unknown;\n\treadonly errors?: readonly ExecutorError[];\n}\n\n/** Per call: the signal that stops the operation, as a client leaving does. */\nexport interface ExecutorCall {\n\t/**\n\t * An aborted signal, before the call or while it runs, resolves to\n\t * `{ errors: [{ extensions: { code: 'OPERATION_ABORTED' } }] }`: it never rejects.\n\t */\n\treadonly signal?: AbortSignal;\n}\n\nexport interface GraphQLExecutorOptions<SchemaCtx = unknown>\n\textends Omit<\n\t\t\tGraxiaOptions<any, GraphQLSchema, any, any>,\n\t\t\t'path' | 'schema' | 'subscriptions' | 'context' | 'plugins'\n\t\t>,\n\t\tLegacyOptions {\n\treadonly schema: GraphQLSchema & { readonly '~context'?: SchemaCtx };\n\treadonly context?: GraxiaOptions['context'];\n\treadonly plugins?: GraxiaOptions['plugins'];\n}\n\n/** Runs one operation in process. */\nexport type GraphQLExecutor<ServerCtx> = ((\n\trequest: ExecutorRequest,\n\tcontext: ServerCtx,\n\tcall?: ExecutorCall,\n) => Promise<ExecutorResult>) & {\n\t/** Releases what the instance holds (plugins' `onDispose`, in-flight operations). A call after it rejects. */\n\tdispose(): Promise<void>;\n};\n\n/** A `GraphQLError` as its plain shape; an error that is already plain stays. */\nfunction plain(error: { toJSON?: () => ExecutorError }): ExecutorError {\n\treturn typeof error.toJSON === 'function'\n\t\t? error.toJSON()\n\t\t: (error as ExecutorError);\n}\n\n/** Runs a GraphQL operation in the process, through `graxia.execute`. Queries and mutations only (graxia refuses a subscription). */\nexport function graphqlExecutor<\n\tSchemaCtx,\n\tServerCtx = Omit<SchemaCtx, 'signal'>,\n>(options: GraphQLExecutorOptions<SchemaCtx>): GraphQLExecutor<ServerCtx> {\n\tconst graxia = createGraxia({\n\t\t...graxiaOptions(\n\t\t\t{ ...options, ide: false },\n\t\t\t{ ws: false, caller: 'graphqlExecutor(' },\n\t\t),\n\t\tcsrf: false,\n\t\tsubscriptions: { sse: false, ws: false },\n\t} as never);\n\tconst run = async (\n\t\trequest: ExecutorRequest,\n\t\tcontext: ServerCtx,\n\t\tcall?: ExecutorCall,\n\t): Promise<ExecutorResult> => {\n\t\tconst body = await (graxia.execute as any)({\n\t\t\tdocument: request.query,\n\t\t\t...(request.operationName !== undefined && {\n\t\t\t\toperationName: request.operationName,\n\t\t\t}),\n\t\t\t...(request.variables !== undefined && {\n\t\t\t\tvariables: request.variables,\n\t\t\t}),\n\t\t\t...(call?.signal !== undefined && { signal: call.signal }),\n\t\t\tserverContext: context,\n\t\t});\n\t\treturn {\n\t\t\t...(body.data !== undefined && { data: body.data }),\n\t\t\t...(body.errors !== undefined && {\n\t\t\t\terrors: body.errors.map(plain),\n\t\t\t}),\n\t\t};\n\t};\n\treturn Object.assign(run, { dispose: () => graxia.dispose() });\n}\nexport type { Empty };\n",
|
|
8
8
|
"/** The IDE of `graphql()`: graxia's GraphiQL or Apollo Sandbox plugin, from alxia's `ide` options. */\n\nimport type { GraxiaPlugin } from '@graxia/core';\nimport {\n\ttype ApolloSandboxOptions,\n\tapolloSandbox,\n\ttype GraphiQLOptions,\n\tgraphiql,\n\ttype SandboxInitialState,\n} from '@graxia/graphiql';\nimport type { SandboxOptions } from './sandbox';\n\n/**\n * The requests the endpoint handler has seen, with the app's dev flag at the\n * moment of each: what the IDE's `enabled` function reads, since graxia hands\n * it the `Request` alone.\n */\nexport type DevOfRequest = WeakMap<Request, boolean>;\n\nexport interface ExplorerOptions {\n\treadonly ide?: 'graphiql' | 'apollo-sandbox' | false | undefined;\n\treadonly graphiql?: GraphiQLOptions | false | undefined;\n\treadonly sandbox?: SandboxOptions | undefined;\n}\n\n/** Defined, by key, so an unset option leaves the default of the plugin alone. */\nfunction defined<T extends object>(\n\tvalues: { [K in keyof T]?: T[K] | undefined },\n): T {\n\treturn Object.fromEntries(\n\t\tObject.entries(values).filter(([, value]) => value !== undefined),\n\t) as T;\n}\n\nfunction sandboxPlugin(\n\tsandbox: SandboxOptions | undefined,\n): GraxiaPlugin<any, any> {\n\tconst options: ApolloSandboxOptions = {\n\t\tenabled: true,\n\t\t...defined<ApolloSandboxOptions>({ title: sandbox?.title }),\n\t\tinitialState: defined<SandboxInitialState>({\n\t\t\tdocument: sandbox?.initialDocument,\n\t\t\theaders: sandbox?.initialHeaders as Record<string, string> | undefined,\n\t\t\tincludeCookies: sandbox?.includeCookies,\n\t\t}),\n\t};\n\treturn apolloSandbox(options) as GraxiaPlugin<any, any>;\n}\n\n/**\n * The IDE plugins: Sandbox for `ide: 'apollo-sandbox'`, nothing for\n * `ide: false` or `graphiql: false`, GraphiQL otherwise. By default GraphiQL\n * answers while the serving app is in dev (`alxia({ dev })`, else\n * `NODE_ENV=development`, read per request from `devs`, which the endpoint\n * handler fills), and everywhere under `ide: 'graphiql'`.\n */\nexport function explorerPlugins(\n\toptions: ExplorerOptions,\n\tdevs: DevOfRequest,\n): GraxiaPlugin<any, any>[] {\n\tconst { ide, graphiql: graphiqlOptions, sandbox } = options;\n\tif (ide === 'apollo-sandbox') return [sandboxPlugin(sandbox)];\n\tif (ide === false || graphiqlOptions === false) return [];\n\treturn [\n\t\tgraphiql({\n\t\t\tenabled:\n\t\t\t\tide === 'graphiql' ? true : (request) => devs.get(request) === true,\n\t\t\t...graphiqlOptions,\n\t\t}) as GraxiaPlugin<any, any>,\n\t];\n}\n",
|
|
9
|
-
"/**\n * The plugin that tells the observers around the endpoint — `@alxia/logger`,\n * `@alxia/telemetry` — which operation graxia runs. Over HTTP it reports the\n * request's operation (`reportOperation`). Over a WebSocket, whose upgrade\n * was answered long before, it starts and ends each operation\n * (`startOperation`) from graxia's `onExecute` and `onSubscribe` hooks and\n * the operation's `signal`, as graxia's guide to observing each socket\n * operation describes; a document refused by validation never executes, so\n * `onValidate` tells that one, finding the socket through the `serverContext`\n * graxia gives it. A throwing subscription source reaches `onResultChunk` as\n * an error chunk, which ends the operation with errors.\n */\nimport {\n\ttype OperationOutcome,\n\treportOperation,\n\tstartOperation,\n} from '@alxia/core';\nimport { createStateKey, definePlugin } from '@graxia/core';\nimport {
|
|
9
|
+
"/**\n * The plugin that tells the observers around the endpoint — `@alxia/logger`,\n * `@alxia/telemetry` — which operation graxia runs. Over HTTP it reports the\n * request's operation (`reportOperation`). Over a WebSocket, whose upgrade\n * was answered long before, it starts and ends each operation\n * (`startOperation`) from graxia's `onExecute` and `onSubscribe` hooks and\n * the operation's `signal`, as graxia's guide to observing each socket\n * operation describes; a document refused by validation never executes, so\n * `onValidate` tells that one, finding the socket through the `serverContext`\n * graxia gives it. A throwing subscription source reaches `onResultChunk` as\n * an error chunk, which ends the operation with errors. Under `@defer` and\n * `@stream` over a socket, the operation ends with its last payload, with\n * `errors` when one carried errors, or once with the outcome so far when its\n * client leaves.\n */\nimport {\n\ttype OperationOutcome,\n\treportOperation,\n\tstartOperation,\n} from '@alxia/core';\nimport { createStateKey, definePlugin } from '@graxia/core';\nimport {\n\ttype DocumentNode,\n\ttype ExperimentalIncrementalExecutionResults,\n\tgetOperationAST,\n\ttype LegacyExperimentalIncrementalExecutionResults,\n} from 'graphql';\n\ntype Report = Parameters<typeof reportOperation>[1];\n\nconst nameKey = createStateKey<string | null>('alxia-operation-name');\nconst openKey = createStateKey<{ outcome: OperationOutcome }>(\n\t'alxia-operation-open',\n);\n\ninterface Executed {\n\treadonly document: DocumentNode;\n\treadonly operationName?: string | null | undefined;\n\treadonly contextValue: unknown;\n}\n\nfunction describe(\n\tdocument: DocumentNode,\n\tname: string | null | undefined,\n): Report | undefined {\n\tconst operation = getOperationAST(document, name);\n\tif (operation === undefined || operation === null) return undefined;\n\treturn { type: operation.operation, name: operation.name?.value };\n}\n\nconst isStream = (result: unknown): boolean =>\n\ttypeof result === 'object' &&\n\tresult !== null &&\n\tSymbol.asyncIterator in result;\n\ntype IncrementalResults =\n\t| ExperimentalIncrementalExecutionResults\n\t| LegacyExperimentalIncrementalExecutionResults;\n\n/** An `@defer`/`@stream` result: its first payload, then the rest (graxia's own guard). */\nconst isIncremental = (result: unknown): result is IncrementalResults =>\n\ttypeof result === 'object' &&\n\tresult !== null &&\n\t'initialResult' in result &&\n\ttypeof (result as { subsequentResults?: { next?: unknown } })\n\t\t.subsequentResults?.next === 'function';\n\n/** A payload with errors: its own, or one of its `incremental` or `completed` entries. */\nconst carriesErrors = (chunk: unknown): boolean => {\n\tif (typeof chunk !== 'object' || chunk === null) return false;\n\tconst payload = chunk as {\n\t\terrors?: unknown;\n\t\tincremental?: unknown;\n\t\tcompleted?: unknown;\n\t};\n\tif (Array.isArray(payload.errors) && payload.errors.length > 0) return true;\n\treturn [payload.incremental, payload.completed].some(\n\t\t(entries) =>\n\t\t\tArray.isArray(entries) &&\n\t\t\tentries.some(\n\t\t\t\t(entry) =>\n\t\t\t\t\ttypeof entry === 'object' &&\n\t\t\t\t\tentry !== null &&\n\t\t\t\t\tArray.isArray((entry as { errors?: unknown }).errors) &&\n\t\t\t\t\t(entry as { errors: unknown[] }).errors.length > 0,\n\t\t\t),\n\t);\n};\n\n/**\n * `chunks`, ending the operation once: when it is done, when a payload\n * rejects (`errors`), or when its client leaves (`return`), with the outcome\n * so far. A plain iterator and not a generator, so that `return()` reaches\n * `chunks` at once even while a `next()` is pending, as graxia's source needs.\n */\nfunction observed<Chunks extends AsyncGenerator<unknown, void, void>>(\n\tchunks: Chunks,\n\tprogress: { outcome: OperationOutcome },\n\tend: (outcome: OperationOutcome) => void,\n): Chunks {\n\tconst wrapped = {\n\t\tasync next() {\n\t\t\ttry {\n\t\t\t\tconst step = await chunks.next();\n\t\t\t\tif (step.done === true) end(progress.outcome);\n\t\t\t\telse if (carriesErrors(step.value)) progress.outcome = 'errors';\n\t\t\t\treturn step;\n\t\t\t} catch (error) {\n\t\t\t\tprogress.outcome = 'errors';\n\t\t\t\tend('errors');\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\treturn(value?: void) {\n\t\t\tend(progress.outcome);\n\t\t\treturn chunks.return(value);\n\t\t},\n\t\tthrow(error?: unknown) {\n\t\t\treturn chunks.throw(error);\n\t\t},\n\t\t[Symbol.asyncIterator]() {\n\t\t\treturn wrapped;\n\t\t},\n\t};\n\t// graphql's generator type also asks for `Symbol.asyncDispose`, which\n\t// graxia never calls: the cast stands for that one member.\n\treturn wrapped as unknown as Chunks;\n}\n\nconst failed = (result: unknown): OperationOutcome =>\n\ttypeof result === 'object' && result !== null && 'errors' in result\n\t\t? 'errors'\n\t\t: 'ok';\n\n/** A graxia plugin reporting each operation graxia executes or subscribes to. */\nexport function reportsOperations() {\n\treturn definePlugin({\n\t\tname: 'alxia-report-operations',\n\t\tonParse: ({ params, state }) => {\n\t\t\tstate.set(nameKey, params.operationName ?? null);\n\t\t},\n\t\tonValidate: ({ document, serverContext, state }) => {\n\t\t\treturn ({ errors }) => {\n\t\t\t\tif (errors === undefined || errors.length === 0) return;\n\t\t\t\tconst report = describe(document, state.get(nameKey));\n\t\t\t\tif (report !== undefined)\n\t\t\t\t\tstartOperation(serverContext, report)('errors');\n\t\t\t};\n\t\t},\n\t\tonExecute: ({ args }) => {\n\t\t\tconst { document, operationName, contextValue } = args as Executed;\n\t\t\tconst report = describe(document, operationName);\n\t\t\tif (report === undefined) return;\n\t\t\treportOperation(contextValue as object, report);\n\t\t\tconst end = startOperation(contextValue as object, report);\n\t\t\treturn ({ result, setResult }) => {\n\t\t\t\tif (!isIncremental(result)) return end(failed(result));\n\t\t\t\t// `@defer`/`@stream`: the operation lasts until its last payload, or\n\t\t\t\t// until its client leaves.\n\t\t\t\tconst progress = {\n\t\t\t\t\toutcome: carriesErrors(result.initialResult)\n\t\t\t\t\t\t? ('errors' as const)\n\t\t\t\t\t\t: ('ok' as const),\n\t\t\t\t};\n\t\t\t\tconst signal = (contextValue as { signal?: AbortSignal }).signal;\n\t\t\t\tconst onAbort = () => finish(progress.outcome);\n\t\t\t\tconst finish = (outcome: OperationOutcome) => {\n\t\t\t\t\tsignal?.removeEventListener('abort', onAbort);\n\t\t\t\t\tend(outcome);\n\t\t\t\t};\n\t\t\t\tsignal?.addEventListener('abort', onAbort, { once: true });\n\t\t\t\tconst subsequentResults = observed(\n\t\t\t\t\tresult.subsequentResults,\n\t\t\t\t\tprogress,\n\t\t\t\t\tfinish,\n\t\t\t\t);\n\t\t\t\t// The spread of a union keeps both formats' members apart, so\n\t\t\t\t// TypeScript cannot see the result as one of them again.\n\t\t\t\tsetResult({ ...result, subsequentResults } as typeof result);\n\t\t\t};\n\t\t},\n\t\tonSubscribe: ({ args, state }) => {\n\t\t\tconst { document, operationName, contextValue } = args as Executed;\n\t\t\tconst report = describe(document, operationName);\n\t\t\tif (report === undefined) return;\n\t\t\tconst context = contextValue as { signal?: AbortSignal };\n\t\t\treportOperation(context, report);\n\t\t\tconst end = startOperation(context, report);\n\t\t\tconst open = { outcome: 'ok' as OperationOutcome };\n\t\t\tstate.set(openKey, open);\n\t\t\tcontext.signal?.addEventListener('abort', () => end(open.outcome), {\n\t\t\t\tonce: true,\n\t\t\t});\n\t\t\t// A stream is created; a refusal arrives as a result, not a stream.\n\t\t\treturn ({ result }) => {\n\t\t\t\tif (isStream(result)) return;\n\t\t\t\topen.outcome = failed(result);\n\t\t\t\tend(open.outcome);\n\t\t\t};\n\t\t},\n\t\tonResultChunk: ({ chunk, state }) => {\n\t\t\tconst open = state.get(openKey);\n\t\t\tif (open !== undefined && failed(chunk) === 'errors') {\n\t\t\t\topen.outcome = 'errors';\n\t\t\t}\n\t\t},\n\t});\n}\n",
|
|
10
10
|
"/** The options of the Yoga endpoint that no longer exist, refused with the fix. */\nexport interface RemovedOptions {\n\t/** Removed: unexpected failures go to graxia's `onUnexpected` (`console.error`, off in production); log requests with `@alxia/logger`. */\n\treadonly logging?: never;\n\t/** Removed: graxia generates its own `x-request-id` and never echoes the client's; the app's own id is `@alxia/core`'s. */\n\treadonly requestId?: never;\n\t/** Removed: mount `@alxia/cors` on the app before `graphql()`. */\n\treadonly cors?: never;\n\t/** Removed with `sameOrigin()`: use `csrf: { sameOrigin: true }` (off by default; the CSRF header check is on). */\n\treadonly sameOrigin?: never;\n}\n\nconst FIXES: Readonly<Record<string, string>> = {\n\tlogging:\n\t\t\"`logging` was Yoga's. Unexpected failures go to graxia's `onUnexpected` (console.error by default, off in production); log requests with `@alxia/logger`\",\n\trequestId:\n\t\t\"`requestId` was Yoga's. Graxia generates its own `x-request-id` and never echoes the client's; the app's own id is `@alxia/core`'s\",\n\tcors: '`cors` is gone. Mount `@alxia/cors` on the app before `graphql()`',\n\tsameOrigin:\n\t\t'`sameOrigin` is gone. Use `csrf: { sameOrigin: true }` (off by default; the CSRF header check is on)',\n};\n\n/** Throws, where `graphql()` is declared, for an option that was removed. */\nexport function rejectRemoved(\n\toptions: object,\n\tcaller: 'graphql(app' | 'graphqlExecutor(' = 'graphql(app',\n): void {\n\tfor (const name of Object.keys(FIXES)) {\n\t\tif (\n\t\t\tname in options &&\n\t\t\t(options as Record<string, unknown>)[name] !== undefined\n\t\t) {\n\t\t\tconst call =\n\t\t\t\tcaller === 'graphql(app'\n\t\t\t\t\t? `graphql(app, { ${name} })`\n\t\t\t\t\t: `graphqlExecutor({ ${name} })`;\n\t\t\tthrow new TypeError(`${call}: ${FIXES[name]}`);\n\t\t}\n\t}\n}\n",
|
|
11
11
|
"/**\n * What `graphql()` and `graphqlExecutor()` share: alxia's options mapped\n * onto `createGraxia`'s, the legacy names (`maxTokens`, `maxNesting`,\n * `parseCache`, `maskedErrors`) kept, and the operation reporter.\n */\nimport type { GraxiaOptions } from '@graxia/core';\nimport {\n\ttype DevOfRequest,\n\ttype ExplorerOptions,\n\texplorerPlugins,\n} from './explorer';\nimport { reportsOperations } from './operation';\nimport { rejectRemoved } from './removed';\n\nexport type { RemovedOptions } from './removed';\n\n/** The cache sizes of the parse cache: graxia's `caches.parse`. */\nexport interface ParseCacheOptions {\n\t/** graxia's `caches.parse.maxBytes`: the estimated bytes of sources kept (64 MiB by default). */\n\treadonly maxBytes?: number;\n\treadonly max?: number;\n\t/** Milliseconds. */\n\treadonly ttl?: number;\n}\n\nexport interface LegacyOptions {\n\t/** @deprecated Use `limits: { tokens }`. Works until the next minor. */\n\treadonly maxTokens?: number | false;\n\t/** @deprecated Use `limits: { nesting }`. Works until the next minor. */\n\treadonly maxNesting?: number | false;\n\t/** @deprecated Use `caches: { parse }`, or `caches: false`. Works until the next minor. */\n\treadonly parseCache?: false | ParseCacheOptions;\n\t/** `false` is graxia's `maskErrors: false`. */\n\treadonly maskedErrors?: boolean;\n}\n\ninterface Wiring {\n\t/** Filled by the endpoint handler; the executor serves no page and gives none. */\n\treadonly devs?: DevOfRequest | undefined;\n\treadonly ws: false | { keepAlive?: number | false | undefined };\n\treadonly bodyLimit?: number | undefined;\n\t/** Whose name an error carries. */\n\treadonly caller?: 'graphqlExecutor(' | undefined;\n}\n\ntype Limits = NonNullable<GraxiaOptions['limits']>;\ntype Caches = GraxiaOptions['caches'];\ntype Subscriptions = NonNullable<GraxiaOptions['subscriptions']>;\n\nfunction limitsOf(\n\tlegacy: {\n\t\treadonly maxTokens: number | false | undefined;\n\t\treadonly maxNesting: number | false | undefined;\n\t},\n\tbodyLimit: number | undefined,\n\tlimits: GraxiaOptions['limits'],\n): Limits {\n\treturn {\n\t\t...(legacy.maxTokens === undefined ? {} : { tokens: legacy.maxTokens }),\n\t\t...(legacy.maxNesting === undefined ? {} : { nesting: legacy.maxNesting }),\n\t\t...(bodyLimit === undefined ? {} : { bodyBytes: bodyLimit }),\n\t\t...limits,\n\t};\n}\n\nfunction cachesOf(\n\tparseCache: LegacyOptions['parseCache'],\n\tcaches: Caches,\n): Caches {\n\tif (caches !== undefined) return caches;\n\tif (parseCache === undefined || parseCache === false) {\n\t\treturn parseCache === false ? false : undefined;\n\t}\n\treturn {\n\t\tparse: {\n\t\t\t...(parseCache.maxBytes === undefined\n\t\t\t\t? {}\n\t\t\t\t: { maxBytes: parseCache.maxBytes }),\n\t\t\t...(parseCache.max === undefined ? {} : { max: parseCache.max }),\n\t\t\t...(parseCache.ttl === undefined ? {} : { ttlMs: parseCache.ttl }),\n\t\t},\n\t};\n}\n\nfunction subscriptionsOf(ws: Wiring['ws']): Subscriptions {\n\tif (ws === false) return { sse: true, ws: false };\n\tconst { keepAlive } = ws;\n\tif (keepAlive === undefined) return { sse: true, ws: true };\n\treturn {\n\t\tsse: true,\n\t\tws: { keepAliveMs: keepAlive === false ? 0 : Math.ceil(keepAlive) },\n\t};\n}\n\n/**\n * @alxia/telemetry spans the operations; graxia's own operation span would\n * double it, so only its step spans (parse, validate, execute) stay, as\n * children of the active host span. The default is merged under a given\n * `telemetry` object, so one that sets only `resolverSpans` keeps it; `false`\n * turns every span off.\n */\nfunction telemetryOf(telemetry: GraxiaOptions['telemetry']) {\n\tif (telemetry === false) return false;\n\treturn { operationSpans: false, ...telemetry };\n}\n\nexport function graxiaOptions(options: object, wiring: Wiring): GraxiaOptions {\n\trejectRemoved(options, wiring.caller);\n\tconst {\n\t\tmaxTokens,\n\t\tmaxNesting,\n\t\tparseCache,\n\t\tmaskedErrors,\n\t\tide,\n\t\tgraphiql,\n\t\tsandbox,\n\t\tpath: _path,\n\t\tws: _ws,\n\t\tbodyLimit: _bodyLimit,\n\t\tplugins = [],\n\t\tlimits,\n\t\tcaches,\n\t\ttelemetry,\n\t\t...rest\n\t} = options as GraxiaOptions &\n\t\tLegacyOptions &\n\t\tExplorerOptions & {\n\t\t\tpath?: unknown;\n\t\t\tws?: unknown;\n\t\t\tbodyLimit?: unknown;\n\t\t};\n\treturn {\n\t\t...rest,\n\t\ttelemetry: telemetryOf(telemetry),\n\t\tpath: false,\n\t\tplugins: [\n\t\t\t...plugins,\n\t\t\t...explorerPlugins(\n\t\t\t\t{ ide, graphiql, sandbox },\n\t\t\t\twiring.devs ?? new WeakMap(),\n\t\t\t),\n\t\t\treportsOperations(),\n\t\t],\n\t\tlimits: limitsOf({ maxTokens, maxNesting }, wiring.bodyLimit, limits),\n\t\tcaches: cachesOf(parseCache, caches),\n\t\t...(maskedErrors === false ? { maskErrors: false } : {}),\n\t\tsubscriptions: subscriptionsOf(wiring.ws),\n\t} as GraxiaOptions;\n}\n",
|
|
12
12
|
"import type { Alxia, BaseContext, Empty, RoutePath } from '@alxia/core';\nimport {\n\ttype ContextInit,\n\ttype ContextOf,\n\ttype CoreContext,\n\tcreateGraxia,\n\ttype GraxiaOptions,\n\ttype GraxiaPlugin,\n} from '@graxia/core';\nimport type { GraphiQLOptions } from '@graxia/graphiql';\nimport type { GraphQLSchema } from 'graphql';\nimport { declareEndpoint } from './endpoint';\nimport type { DevOfRequest } from './explorer';\nimport { graphqlHandler } from './handler';\nimport {\n\tgraxiaOptions,\n\ttype LegacyOptions,\n\ttype RemovedOptions,\n} from './options';\nimport type { SandboxOptions } from './sandbox';\nimport { checkKeepAlive, type GraphQLWsOptions, graphqlSocket } from './ws';\n\n/** The parts of a route's context graxia owns, or that mean nothing to a resolver. */\ntype RouteOnly =\n\t| 'params'\n\t| 'query'\n\t| 'headers'\n\t| 'cookies'\n\t| 'body'\n\t| 'reply'\n\t| 'redirect';\n\n/**\n * What alxia hands graxia for each request as its `serverContext`: the\n * context its middlewares built with `request`, `url`, `ip` and `set`.\n */\nexport type ServerContext<Ctx> = Omit<BaseContext & Ctx, RouteOnly>;\n\n/** What an operation over WebSocket adds to its context: the client's `connectionParams`. */\nexport interface GraphQLWsContext {\n\treadonly connectionParams?: Readonly<Record<string, unknown>>;\n}\n\n/**\n * What a resolver reads as its context: graxia's `signal`, the app's, what\n * the `context` option adds, and over WebSocket the `connectionParams`.\n */\nexport type GraphQLContext<App, UserContext = Empty> = App extends {\n\treadonly '~context': infer Ctx;\n}\n\t? CoreContext & ServerContext<Ctx> & GraphQLWsContext & UserContext\n\t: {\n\t\t\treadonly '~error': 'GraphQLContext needs the type of an app: GraphQLContext<typeof app>';\n\t\t};\n\ntype Passed =\n\t| 'path'\n\t| 'schema'\n\t| 'context'\n\t| 'subscriptions'\n\t| 'plugins'\n\t| 'limits'\n\t| 'caches';\n\nexport interface GraphQLOptions<\n\tCtx,\n\tPath extends RoutePath,\n\tSchemaCtx = unknown,\n\tMade extends object = object,\n\tPlugins extends readonly GraxiaPlugin<any, any>[] = readonly GraxiaPlugin<\n\t\tany,\n\t\tany\n\t>[],\n> extends Omit<\n\t\t\tGraxiaOptions<ServerContext<Ctx>, GraphQLSchema, any, Made>,\n\t\t\tPassed\n\t\t>,\n\t\tLegacyOptions,\n\t\tRemovedOptions {\n\treadonly schema: GraphQLSchema & { readonly '~context'?: SchemaCtx };\n\treadonly context?: (\n\t\tinit: ContextInit<ServerContext<Ctx>>,\n\t) => Made | Promise<Made>;\n\treadonly plugins?: Plugins;\n\treadonly limits?: GraxiaOptions['limits'];\n\treadonly caches?: GraxiaOptions['caches'];\n\treadonly ide?: 'graphiql' | 'apollo-sandbox' | false;\n\treadonly graphiql?: GraphiQLOptions | false;\n\treadonly sandbox?: SandboxOptions;\n\treadonly path?: Path;\n\treadonly ws?: boolean | GraphQLWsOptions;\n\treadonly bodyLimit?: number;\n}\n\n/**\n * The parameter of a `context` factory that reads the app's `serverContext`,\n * typed from the app: `context: ({ serverContext }: GraphQLContextInit<typeof app>) => …`,\n * with no `['~context']` to write.\n */\nexport type GraphQLContextInit<App> = App extends {\n\treadonly '~context': infer Ctx;\n}\n\t? ContextInit<ServerContext<Ctx>>\n\t: {\n\t\t\treadonly '~error': 'GraphQLContextInit needs the type of an app: GraphQLContextInit<typeof app>';\n\t\t};\n\ntype ProvidesContext<Provided, Required> = Provided extends Required\n\t? unknown\n\t: {\n\t\t\treadonly schema: `the schema's resolvers read a context the app does not build: missing ${Exclude<\n\t\t\t\tkeyof Required,\n\t\t\t\tkeyof Provided\n\t\t\t> &\n\t\t\t\tstring}`;\n\t\t};\n\n/**\n * A GraphQL endpoint on `app`, served by `@graxia/core`: `GET` and `POST`\n * at `path`, behind every middleware given to `use` on `app` before it.\n */\nexport function graphql<\n\tCtx extends object,\n\tPrefix extends string,\n\tSchemaCtx,\n\tMade extends object = Empty,\n\tconst Path extends RoutePath = '/graphql',\n\tconst Plugins extends readonly GraxiaPlugin<\n\t\tany,\n\t\tany\n\t>[] = readonly GraxiaPlugin<any, any>[],\n>(\n\tapp: Alxia<Ctx, Prefix>,\n\toptions: GraphQLOptions<Ctx, Path, SchemaCtx, Made, Plugins> &\n\t\tProvidesContext<\n\t\t\tCoreContext & ServerContext<Ctx> & Made & ContextOf<Plugins>,\n\t\t\tSchemaCtx\n\t\t>,\n): Alxia<Ctx, Prefix> {\n\tconst { path = '/graphql' as Path, ws = false, bodyLimit } = options;\n\tif (typeof ws === 'object') checkKeepAlive(ws);\n\tconst devs: DevOfRequest = new WeakMap();\n\tdeclareEndpoint(app as never, path, bodyLimit, (bodyBytes) => {\n\t\tconst graxia = createGraxia(\n\t\t\tgraxiaOptions(options, {\n\t\t\t\tdevs,\n\t\t\t\tws: ws === false ? false : ws === true ? {} : ws,\n\t\t\t\tbodyLimit: bodyBytes,\n\t\t\t}) as never,\n\t\t);\n\t\tapp.onStop(() => graxia.dispose());\n\t\treturn {\n\t\t\thandler: graphqlHandler(graxia, devs) as never,\n\t\t\tsocket:\n\t\t\t\tws === false\n\t\t\t\t\t? undefined\n\t\t\t\t\t: graphqlSocket(graxia, path, ws === true ? {} : ws),\n\t\t};\n\t});\n\treturn app as never;\n}\n",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"/**\n * GraphQL over WebSocket: the `graphql-transport-ws` protocol is graxia's.\n * alxia owns `Bun.serve`'s websocket handler, so the route's middleware asks\n * `graxia.upgrade` for the socket's data through a stand-in server that only\n * captures it, and each socket's events are handed to `graxia.websocket`.\n * graxia's `maxPayloadBytes` (1 MiB) is applied by `graxia.serve`, which\n * alxia does not use: a message is bounded by Bun's `maxPayloadLength` (16 MiB\n * by default), as the WebSocket guide says.\n */\nimport type { BaseContext, NextFunction, RoutePath, Socket } from '@alxia/core';\nimport type { Graxia } from '@graxia/core';\nimport { serverContext } from './handler';\n\nexport interface GraphQLWsOptions {\n\t/** Where a client opens its socket. The endpoint's own path by default. */\n\treadonly path?: RoutePath;\n\t/** Milliseconds between pings, or `false` for none. */\n\treadonly keepAlive?: number | false;\n}\n\nconst KEY = 'graxiaSocket';\n\n/** Refuses, where `graphql()` is declared, a `keepAlive` that would ping in a loop. */\nexport function checkKeepAlive(options: GraphQLWsOptions): void {\n\tconst { keepAlive } = options;\n\tif (keepAlive === undefined || keepAlive === false) return;\n\tconst valid =\n\t\ttypeof keepAlive === 'number' &&\n\t\tNumber.isFinite(keepAlive) &&\n\t\tkeepAlive > 0 &&\n\t\tkeepAlive <= 2 ** 31 - 1;\n\tif (!valid) {\n\t\tthrow new TypeError(\n\t\t\t`graphql(app, { ws: { keepAlive: ${keepAlive} } }): keepAlive is the milliseconds between pings, a positive number up to ${2 ** 31 - 1}, or false for none`,\n\t\t);\n\t}\n}\n\nexport function graphqlSocket(\n\tgraxia: Graxia<any>,\n\tendpoint: string,\n\toptions: GraphQLWsOptions,\n) {\n\tasync function graphqlWs(ctx: BaseContext, next: NextFunction) {\n\t\tlet captured: { data: object; headers: HeadersInit } | undefined;\n\t\tconst standIn = {\n\t\t\tupgrade(\n\t\t\t\t_request: Request,\n\t\t\t\tgiven: { data: object; headers: HeadersInit },\n\t\t\t) {\n\t\t\t\tcaptured = given;\n\t\t\t\treturn true;\n\t\t\t},\n\t\t};\n\t\tconst host = serverContext(ctx as never);\n\t\tconst refused = await (graxia.upgrade as any)(ctx.request, standIn, host);\n\t\tif (refused !== undefined || captured === undefined) return refused;\n\t\tfor (const [name, value] of new Headers(captured.headers)) {\n\t\t\tctx.set.headers.set(name, value);\n\t\t}\n\t\treturn next({ [KEY]: captured.data } as never);\n\t}\n\ttype GraphQLSocket = Socket<Record<string, any> & BaseContext, unknown>;\n\tconst handlers = {\n\t\topen(socket: GraphQLSocket) {\n\t\t\tObject.assign(socket.raw.data as object, socket.data[KEY]);\n\t\t\tgraxia.websocket.open?.(socket.raw as never);\n\t\t},\n\t\tasync message(socket: GraphQLSocket, message: unknown) {\n\t\t\tawait graxia.websocket.message?.(socket.raw as never, message as never);\n\t\t},\n\t\tasync close(socket: GraphQLSocket, code: number, reason: string) {\n\t\t\tawait graxia.websocket.close?.(socket.raw as never, code, reason);\n\t\t},\n\t\tdrain(socket: GraphQLSocket) {\n\t\t\tgraxia.websocket.drain?.(socket.raw as never);\n\t\t},\n\t};\n\treturn { path: options.path ?? endpoint, middleware: graphqlWs, handlers };\n}\n",
|
|
16
16
|
"const caches = new WeakMap<object, Map<string, unknown>>();\n\n/**\n * A value loaded at most once per request and key. `request` is any object\n * that lives as long as the request (the resolvers' context); the cache is\n * released with it. A `load` that throws, or returns a promise that rejects,\n * is not kept, so the next call tries again.\n */\nexport function oncePerRequest<T>(\n\trequest: object,\n\tkey: string,\n\tload: () => T,\n): T {\n\tlet cache = caches.get(request);\n\tif (!cache) {\n\t\tcache = new Map();\n\t\tcaches.set(request, cache);\n\t}\n\tif (cache.has(key)) return cache.get(key) as T;\n\tconst loaded = load();\n\tcache.set(key, loaded);\n\tif (loaded instanceof Promise) {\n\t\tconst mine = cache;\n\t\tloaded.catch(() => {\n\t\t\tif (mine.get(key) === loaded) mine.delete(key);\n\t\t});\n\t}\n\treturn loaded;\n}\n\n/**\n * Forgets what `oncePerRequest` kept for this request, so the next call for\n * any key loads again. A call to `oncePerRequest` already in flight keeps its\n * own value; only later calls see the empty cache.\n */\nexport function clearRequestCache(request: object): void {\n\tcaches.delete(request);\n}\n\n/**\n * A mutation's root fields run one after the other in one request, and one\n * may change what a later one reads. `freshPerMutation(resolvers)` returns\n * the resolvers with every function of `Mutation` wrapped to call\n * `clearRequestCache(context)` before it runs: each root mutation field starts\n * with an empty cache, its own sub-fields share it, and a query (no wrapped\n * field) keeps one cache for the whole request. Other types are untouched.\n *\n * It returns the same type it was given: an array of maps (what\n * `createSchema` takes for `resolvers`) stays an array, each map wrapped on its\n * own, so graxia still merges them (a field defined twice throws there) and\n * each map stays checked.\n */\nexport function freshPerMutation<R extends object>(resolvers: R): R;\nexport function freshPerMutation(\n\tresolvers: object | readonly object[],\n): unknown {\n\tif (Array.isArray(resolvers)) {\n\t\treturn resolvers.map((map: object) => freshPerMutation(map));\n\t}\n\treturn wrapMutation(resolvers);\n}\n\nfunction wrapMutation<R extends object>(resolvers: R): R {\n\tconst mutation = (resolvers as { Mutation?: unknown }).Mutation as\n\t\t| Record<string, unknown>\n\t\t| undefined;\n\tif (!mutation) return resolvers;\n\tconst wrapped: Record<string, unknown> = {};\n\tfor (const [name, field] of Object.entries(mutation)) {\n\t\tif (typeof field !== 'function') {\n\t\t\twrapped[name] = field;\n\t\t\tcontinue;\n\t\t}\n\t\twrapped[name] = function (\n\t\t\tthis: unknown,\n\t\t\tparent: unknown,\n\t\t\targs: unknown,\n\t\t\tcontext: unknown,\n\t\t\tinfo: unknown,\n\t\t) {\n\t\t\tif (typeof context === 'object' && context !== null) {\n\t\t\t\tclearRequestCache(context);\n\t\t\t}\n\t\t\treturn field.call(this, parent, args, context, info);\n\t\t};\n\t}\n\treturn { ...resolvers, Mutation: wrapped };\n}\n"
|
|
17
17
|
],
|
|
18
|
-
"mappings": ";AACA;AAAA;AAAA;AAAA;;;AC4BA,IAAM,OAAO,EAAE,MAAM,MAAM,OAAO,UAAU;AAerC,SAAS,aAAgB,CAC/B,QACA,SAC2B;AAAA,EAC3B,QAAQ,QAAQ,SAAS,cAAc,OAAO,WAAW;AAAA,EACzD,MAAM,aAAa,QAAQ,mBAAmB;AAAA,EAC9C,MAAM,WAAW,QAAQ,aAAa,CAAC,UAAmB;AAAA,EAC1D,MAAM,WACL,OAAO,iBAAiB,SACpB,OAA4B,OAAO,eAAe,IAClD;AAAA,EAEL,MAAM,YAAY,KAAK,IAAI;AAAA,EAC3B,IAAI,cAAc;AAAA,EAClB,IAAI,cAAc;AAAA,EAClB,IAAI,WAAW;AAAA,EACf,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EAEJ,MAAM,UAAU,MAAqB;AAAA,IACpC,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,cAAc,YAAY;AAAA,MACzB,IAAI;AAAA,QACH,MAAM,SAAS,SAAS,SAAS;AAAA,QAChC,MAAM;AAAA,OACN;AAAA,IACH,OAAO;AAAA;AAAA,EAGR,MAAM,UAAU,MAAM,KAAK,QAAQ;AAAA,EACnC,IAAI,QAAQ;AAAA,IAAc,QAAQ;AAAA,EAClC;AAAA,IAAK,QAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;AAAA,EAC9D,MAAM,SAAS,MAAM,QAAQ,oBAAoB,SAAS,OAAO;AAAA,EAEjE,MAAM,UAAU,YAAY;AAAA,IAC3B,MAAM,MAAM;AAAA,IACZ,cAAc,KAAK,IAAI;AAAA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OAAO,OAAO,OAAO;AAAA;AAiBf,SAAS,gBAAgB,CAC/B,WACU;AAAA,EACV,IAAI,MAAM,QAAQ,SAAS,GAAG;AAAA,IAC7B,OAAO,UAAU,IAAI,CAAC,QAAgB,iBAAiB,GAAG,CAAC;AAAA,EAC5D;AAAA,EACA,OAAO,aAAa,SAAS;AAAA;AAG9B,SAAS,YAA8B,CAAC,WAAiB;AAAA,EACxD,MAAM,WAAY,UAAqC;AAAA,EAGvD,IAAI,CAAC;AAAA,IAAU,OAAO;AAAA,EACtB,MAAM,UAAmC,CAAC;AAAA,EAC1C,YAAY,MAAM,UAAU,OAAO,QAAQ,QAAQ,GAAG;AAAA,IACrD,IAAI,OAAO,UAAU,YAAY;AAAA,MAChC,QAAQ,QAAQ;AAAA,MAChB;AAAA,IACD;AAAA,IACA,QAAQ,QAAQ,QAAS,CAExB,QACA,MACA,SACA,MACC;AAAA,MACD,IAAI,OAAO,YAAY,YAAY,YAAY,MAAM;AAAA,QACpD,kBAAkB,OAAO;AAAA,MAC1B;AAAA,MACA,OAAO,MAAM,KAAK,MAAM,QAAQ,MAAM,SAAS,IAAI;AAAA;AAAA,EAErD;AAAA,EACA,OAAO,KAAK,WAAW,UAAU,QAAQ;AAAA;",
|
|
19
|
+
"debugId": "30AF2FD9C538C31F64756E2164756E21",
|
|
20
20
|
"names": []
|
|
21
21
|
}
|
package/dist/operation.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** A graxia plugin reporting each operation graxia executes or subscribes to. */
|
|
2
|
-
export declare function reportsOperations(): import("@graxia/core").GraxiaPlugin<import("@graxia/core").Empty, import("@graxia/core").Empty>;
|
|
2
|
+
export declare function reportsOperations(): import("@graxia/core").GraxiaPlugin<import("@graxia/core").Empty, import("@graxia/core").Empty, "alxia-report-operations">;
|
|
3
3
|
//# sourceMappingURL=operation.d.ts.map
|
package/dist/operation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../src/operation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../src/operation.ts"],"names":[],"mappings":"AAsIA,iFAAiF;AACjF,wBAAgB,iBAAiB,+HAwEhC"}
|
package/docs/guide/websockets.md
CHANGED
|
@@ -174,6 +174,10 @@ const app = alxia()
|
|
|
174
174
|
`subscription OnNote`, with `graphql.operation.name` and
|
|
175
175
|
`graphql.operation.type`, an error when answered with errors. No span
|
|
176
176
|
lasts as long as the socket.
|
|
177
|
+
- Under `@defer` and `@stream` over a socket, an operation lasts until its
|
|
178
|
+
last payload (`hasNext: false`), not its first, and ends with errors when a
|
|
179
|
+
deferred fragment or a streamed item failed. It ends once, with the outcome
|
|
180
|
+
so far, when its client leaves.
|
|
177
181
|
- An error is an operation answered with errors: a resolver that threw
|
|
178
182
|
(in `errors[]`), a document that does not validate, a subscription that
|
|
179
183
|
failed. A message that does not parse names no operation, and is not
|
|
@@ -186,7 +190,8 @@ const app = alxia()
|
|
|
186
190
|
they do.
|
|
187
191
|
|
|
188
192
|
`graphql()` tells them with core's `startOperation`, from a graxia plugin on
|
|
189
|
-
`onExecute` and `onSubscribe` (a query or mutation ends with its result,
|
|
193
|
+
`onExecute` and `onSubscribe` (a query or mutation ends with its result, an
|
|
194
|
+
`@defer`/`@stream` one with its last payload, a
|
|
190
195
|
subscription when its `signal` aborts), and they subscribe
|
|
191
196
|
during the upgrade with `onOperation`: no package imports another
|
|
192
197
|
([core's plugin guide](https://github.com/softistx/alxia/blob/develop/packages/core/docs/guide/writing-a-plugin.md)).
|
|
@@ -26,7 +26,7 @@ bun add graphql@^17.1.0
|
|
|
26
26
|
|
|
27
27
|
| Before | After |
|
|
28
28
|
| --- | --- |
|
|
29
|
-
| `graphql-yoga` | `@graxia/core` `^0.10.0 \|\| ^0.11.0` (0.10 sets the HTTP status from errors again) |
|
|
29
|
+
| `graphql-yoga` | `@graxia/core` `^0.10.0 \|\| ^0.11.0 \|\| ^0.12.0` (0.10 sets the HTTP status from errors again) |
|
|
30
30
|
| `graphql-ws` (for `ws`) | nothing: graxia speaks `graphql-transport-ws` |
|
|
31
31
|
| bundled GraphiQL of Yoga | `@graxia/graphiql` `^0.2.4` (required) |
|
|
32
32
|
| Envelop plugins | not a peer: install `@graxia/envelop` yourself to use Envelop plugins |
|
|
@@ -63,6 +63,12 @@ cast is needed. A field defined twice **throws** a `GraxiaConfigError` naming
|
|
|
63
63
|
(Yoga's tools let the last one win). `freshPerMutation` takes the same array
|
|
64
64
|
and returns an array, each map wrapped on its own.
|
|
65
65
|
|
|
66
|
+
`createSchema` also adds the `@cost` and `@listSize` directives (for the
|
|
67
|
+
operation cost) and, unless `incremental: false`, `@defer` and `@stream` to the
|
|
68
|
+
schema (a directive the SDL already declares is kept). A `schema.graphql`
|
|
69
|
+
printed from the Yoga schema, or a snapshot of it, no longer matches: print it
|
|
70
|
+
again from the new schema and commit the result.
|
|
71
|
+
|
|
66
72
|
```ts
|
|
67
73
|
// file: src/schema-maps.ts
|
|
68
74
|
import { createSchema } from '@graxia/core';
|
|
@@ -126,13 +132,15 @@ export const plugins = [fromEnvelop([useDepthLimit({ maxDepth: 8 })])];
|
|
|
126
132
|
```
|
|
127
133
|
|
|
128
134
|
**Janus.** `useJanus()` was a Yoga plugin. Use `@softistx/janus-graphql`
|
|
129
|
-
`^0.
|
|
135
|
+
`^0.37.0` (or later) and its `/graxia` entry, `janusGraxia(options)`, in `plugins`.
|
|
130
136
|
`fromEnvelop` refuses the old plugin at boot, since it relies on Yoga's
|
|
131
|
-
`onResponse` hook; wrapping it is not a way around.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
`@
|
|
137
|
+
`onResponse` hook; wrapping it is not a way around. If the app renames error
|
|
138
|
+
codes with `mapCode`, pass the same `mapCode` to `janusGraxia` and
|
|
139
|
+
`janusGraxiaMaskError`: from 0.37.0 `janusGraxia` maps the codes of every
|
|
140
|
+
result (janus denials, already-coded errors, each subscription event and
|
|
141
|
+
`@defer` payload), and `janusGraxiaMaskError` those of the errors graxia masks.
|
|
142
|
+
See janus-graphql's
|
|
143
|
+
[graxia guide](https://github.com/softistx/nxgt-janus/blob/develop/packages/janus-graphql/docs/guide/graxia.md).
|
|
136
144
|
|
|
137
145
|
```diff
|
|
138
146
|
-import { useJanus } from '@softistx/janus-graphql';
|
|
@@ -152,6 +160,9 @@ Many Yoga plugins have a graxia option now: depth, aliases and cost limits
|
|
|
152
160
|
`respond(new Response(null, { status: 401 }))` answers; a `throw` is an
|
|
153
161
|
unexpected failure and answers 500. `onResponse` has no `respond`: it
|
|
154
162
|
replaces the response with `setResponse`.
|
|
163
|
+
- **`respond` stops the plugins after it.** Once a plugin answers with
|
|
164
|
+
`respond`, the later plugins' hooks of that stage do not run. Put the plugins
|
|
165
|
+
that only add headers or record something before the ones that may refuse.
|
|
155
166
|
- **Per-operation checks go in `onParams`.** `onRequest` runs for every
|
|
156
167
|
request that reaches the endpoint, the GraphiQL page's `GET` included, so a
|
|
157
168
|
check there blocks the IDE too.
|
|
@@ -167,6 +178,51 @@ export const refuse = (headers?: Headers): Response =>
|
|
|
167
178
|
new Response(null, { status: 401, ...(headers ? { headers } : {}) });
|
|
168
179
|
```
|
|
169
180
|
|
|
181
|
+
- **`setResult` in the after-hook of `onValidate` is refused.** An Envelop
|
|
182
|
+
plugin (through `@graxia/envelop`) that calls `setResult` there gets a
|
|
183
|
+
`GraxiaConfigError`, by design. Call `setResult` in `onValidate` itself, or
|
|
184
|
+
add validation rules (`addValidationRule`, or `setValidationFn` to wrap the rules) instead of rewriting the
|
|
185
|
+
result afterwards. See `@graxia/envelop`'s
|
|
186
|
+
[troubleshooting](https://github.com/softistx/graxia/blob/develop/packages/envelop/docs/troubleshooting.md)
|
|
187
|
+
("calls setResult in the after-hook of onValidate…") and the hook table of
|
|
188
|
+
its [Envelop guide](https://github.com/softistx/graxia/blob/develop/packages/envelop/docs/guide/envelop.md).
|
|
189
|
+
- **Variable-coercion errors carry `extensions.code: 'BAD_USER_INPUT'`**
|
|
190
|
+
from graxia. Errors graphql raises before any field runs (a bad
|
|
191
|
+
variable, an unknown operation name) are stamped with it when they have no
|
|
192
|
+
code of their own. App code or specs that reshape those errors into a code of
|
|
193
|
+
their own, or assert the old absence of a code, must accept `BAD_USER_INPUT`.
|
|
194
|
+
- **graxia's operation limits are on by default.** `limits` caps `depth` (12),
|
|
195
|
+
`aliases` (30), `directives` (50), `rootFields` (20) and `cost` (5 000). An
|
|
196
|
+
app that already has its own depth, alias, root-field or cost rules (or specs
|
|
197
|
+
that probe their thresholds) turns graxia's off, or aligns the two:
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
// file: src/limits.ts
|
|
201
|
+
import type { OperationLimits } from '@graxia/core';
|
|
202
|
+
|
|
203
|
+
// Turn off what the app's own rules already enforce…
|
|
204
|
+
export const off: OperationLimits = {
|
|
205
|
+
depth: false,
|
|
206
|
+
aliases: false,
|
|
207
|
+
rootFields: false,
|
|
208
|
+
directives: false,
|
|
209
|
+
cost: false,
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// …or keep graxia's and align the numbers.
|
|
213
|
+
export const aligned: OperationLimits = { depth: 8, cost: { max: 2_000 } };
|
|
214
|
+
// Pass one of them as `createGraxia({ …, limits: off })`.
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
- **A hard-coded `status: 400` on validation refusals is redundant under
|
|
218
|
+
`application/graphql-response+json`.** graxia honours
|
|
219
|
+
`extensions.http.status`, and a validation failure already answers 400 for a
|
|
220
|
+
client that accepts `application/graphql-response+json`; for plain
|
|
221
|
+
`application/json` the unchanged default is 200. Keep an explicit status only
|
|
222
|
+
to force a code for plain JSON clients, and set it as
|
|
223
|
+
`extensions: { http: { status: 400 } }` on the error rather than in a layer
|
|
224
|
+
around the server.
|
|
225
|
+
|
|
170
226
|
## Options
|
|
171
227
|
|
|
172
228
|
| Option | Now |
|
|
@@ -204,6 +260,10 @@ that offers no subprotocol now gets an HTTP 400 at the upgrade. See
|
|
|
204
260
|
no pings ([troubleshooting](troubleshooting.md#typeerror-graphqlapp--ws--keepalive-0---keepalive-is-the-milliseconds-between-pings-a-positive-number-up-to-2147483647-or-false-for-none)).
|
|
205
261
|
- A binary frame is refused: the socket closes with `4400`, so send text
|
|
206
262
|
frames ([troubleshooting](troubleshooting.md#a-websocket-closes-with-4400-after-the-first-message)).
|
|
263
|
+
- A subscription sent as a plain JSON `POST` (no `Accept: text/event-stream`)
|
|
264
|
+
is refused with a `SUBSCRIPTION_NOT_SUPPORTED` error whose message names the
|
|
265
|
+
transports that are on. Clients must send `Accept: text/event-stream` or use
|
|
266
|
+
the WebSocket.
|
|
207
267
|
|
|
208
268
|
## IDE
|
|
209
269
|
|
|
@@ -267,18 +327,26 @@ prefix, `GraphQLContext<typeof app>`, `oncePerRequest`, `freshPerMutation`,
|
|
|
267
327
|
2. Swap the peers: remove `graphql-yoga` and `graphql-ws`, add `@graxia/core`,
|
|
268
328
|
`@graxia/graphiql`; add `@graxia/envelop` only to use Envelop plugins.
|
|
269
329
|
3. Import `createSchema` from `@graxia/core` and curry it: `createSchema<Ctx>()({ … })`;
|
|
270
|
-
pass several resolver maps as an array, not a cast.
|
|
330
|
+
pass several resolver maps as an array, not a cast; print `schema.graphql`
|
|
331
|
+
again (graxia adds `@cost`, `@listSize` and, unless `incremental: false`,
|
|
332
|
+
`@defer`, `@stream`).
|
|
271
333
|
4. Annotate the `context` option's argument with `ServerContext`, and read the
|
|
272
334
|
app's values from `serverContext`.
|
|
273
|
-
5. Rewrite each Yoga plugin (`definePlugin`) or wrap it (`fromEnvelop`)
|
|
335
|
+
5. Rewrite each Yoga plugin (`definePlugin`) or wrap it (`fromEnvelop`), the
|
|
336
|
+
plugins that only add headers before the ones that `respond`.
|
|
274
337
|
6. Rename `maxTokens`, `maxNesting`, `parseCache` and `maskedErrors` to
|
|
275
338
|
`limits`, `caches` and `maskErrors`.
|
|
276
339
|
7. Replace `sameOrigin()`, `renderSandbox`, `logging`, `requestId` and `cors`.
|
|
277
340
|
8. Send a CSRF header from every client that uses `GET` or a non-JSON `POST`.
|
|
278
341
|
9. Match refusals by their code, not by Yoga's messages.
|
|
279
342
|
10. Write `ws: { keepAlive: false }` instead of `keepAlive: 0`, send text frames
|
|
280
|
-
over WebSocket,
|
|
343
|
+
over WebSocket, send subscriptions with `Accept: text/event-stream` (or over
|
|
344
|
+
WebSocket), and read `OPERATION_ABORTED` from an aborted executor call.
|
|
281
345
|
11. Call `await executor.dispose()` when a `graphqlExecutor` is done (a spec's
|
|
282
346
|
`afterAll`, a job's shutdown).
|
|
283
|
-
12.
|
|
347
|
+
12. Replace `setResult` in an `onValidate` after-hook, accept
|
|
348
|
+
`extensions.code: 'BAD_USER_INPUT'` on variable errors, turn off or align
|
|
349
|
+
graxia's default `limits` with the app's own, and drop a redundant
|
|
350
|
+
hard-coded `status: 400`.
|
|
351
|
+
13. Run the app's specs, then `graphqlClient` against a few refusals (an
|
|
284
352
|
oversized body, a mutation over `GET`, a missing header).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alxia/graphql",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.3",
|
|
4
4
|
"description": "GraphQL for alxia served by @graxia/core: its plugins, subscriptions over SSE or WebSocket and GraphiQL, behind the app's hooks, its resolvers reading the app's typed context",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"@alxia/telemetry": "^0.9.4",
|
|
53
53
|
"@envelop/core": "^6.0.1",
|
|
54
54
|
"@envelop/depth-limit": "^7.2.1",
|
|
55
|
-
"@graxia/core": "^0.
|
|
56
|
-
"@graxia/envelop": "^0.1.
|
|
57
|
-
"@graxia/graphiql": "^0.2.
|
|
55
|
+
"@graxia/core": "^0.12.0",
|
|
56
|
+
"@graxia/envelop": "^0.1.6",
|
|
57
|
+
"@graxia/graphiql": "^0.2.6",
|
|
58
58
|
"@softistx/telemetry": "^0.5.0",
|
|
59
59
|
"@types/bun": "^1.4.4",
|
|
60
60
|
"dataloader": "^2.2.3",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@alxia/core": "^0.27.0",
|
|
65
65
|
"graphql": "^17.1.0",
|
|
66
66
|
"typescript": "^6.0.3 || ^7.0.0",
|
|
67
|
-
"@graxia/core": "^0.10.0 || ^0.11.0",
|
|
67
|
+
"@graxia/core": "^0.10.0 || ^0.11.0 || ^0.12.0",
|
|
68
68
|
"@graxia/graphiql": "^0.2.4"
|
|
69
69
|
}
|
|
70
70
|
}
|