@leaven-graphql/nestjs 0.2.1 → 0.2.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 +2 -0
- package/dist/driver.d.ts +27 -3
- package/dist/driver.d.ts.map +1 -1
- package/dist/graphql-driver.d.ts +6 -0
- package/dist/graphql-driver.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +60 -13
- package/dist/subscriptions.d.ts +4 -1
- package/dist/subscriptions.d.ts.map +1 -1
- package/dist/types.d.ts +14 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -596,6 +596,7 @@ export class SchemaService {
|
|
|
596
596
|
| `cache` | `DocumentCacheConfig \| boolean` | - | Document cache configuration |
|
|
597
597
|
| `maxComplexity` | `number` | - | Maximum query complexity. Enforced by the executor before any resolver runs — an over-budget document is rejected with a `ComplexityError` |
|
|
598
598
|
| `maxDepth` | `number` | - | Maximum query depth. **Only recorded on the context** (as `_queryDepth`) for `DepthGuard`, so it is not enforced on `LeavenModule`'s HTTP path — see the caveat under [Features](#features). The `LeavenGraphQLDriver` path enforces it in the executor |
|
|
599
|
+
| `parseOptions` | `ParseOptions` | `{ maxTokens: 10000 }` | Parser limits (core executor shape). Applied by the executor, the guard query analysis and the subscription transport's operation-type detection, so an oversized document is never parsed in full; over the limit it is rejected through the executor's normal error response. Set `maxTokens: Infinity` to opt out |
|
|
599
600
|
| `metrics` | `boolean` | `false` | Enable execution metrics |
|
|
600
601
|
| `context` | `ContextFactory` | - | Custom context factory |
|
|
601
602
|
| `formatError` | `FormatErrorFn` | - | Error formatting function |
|
|
@@ -704,6 +705,7 @@ constructs a `LeavenExecutor` over it and serves `POST <path>` (plus
|
|
|
704
705
|
| `metrics` | `boolean` | Collect per-operation metrics and expose them under `extensions.metrics` |
|
|
705
706
|
| `maxComplexity` | `number` | Rejected by the executor before any resolver runs |
|
|
706
707
|
| `maxDepth` | `number` | Rejected by the executor at parse time |
|
|
708
|
+
| `parseOptions` | `ParseOptions` | Parser limits for the executor. `maxTokens` defaults to `10000`; `Infinity` opts out |
|
|
707
709
|
| `playground` | `boolean` | Serve GraphiQL on `GET <path>` |
|
|
708
710
|
| `subscriptionEndpoint` | `string` | WebSocket endpoint advertised to GraphiQL |
|
|
709
711
|
| `formatError` | `(error) => error` | Final transformation applied to every response error |
|
package/dist/driver.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { type OnModuleInit, type OnModuleDestroy } from '@nestjs/common';
|
|
8
8
|
import { type GraphQLSchema, type DocumentNode } from 'graphql';
|
|
9
|
-
import { LeavenExecutor } from '@leaven-graphql/core';
|
|
9
|
+
import { LeavenExecutor, type ParseOptions } from '@leaven-graphql/core';
|
|
10
10
|
import type { LeavenModuleOptions, GqlContext, GraphQLFormattedError } from './types';
|
|
11
11
|
/**
|
|
12
12
|
* Request handler result
|
|
@@ -22,17 +22,31 @@ export interface HandlerResult<TData = Record<string, unknown>> {
|
|
|
22
22
|
* This driver integrates Leaven's high-performance GraphQL execution
|
|
23
23
|
* with NestJS's dependency injection and module system.
|
|
24
24
|
*/
|
|
25
|
+
/**
|
|
26
|
+
* Default `parseOptions.maxTokens`: generous for real documents, but bounds
|
|
27
|
+
* the lexing, parsing and validation work one request can demand.
|
|
28
|
+
*/
|
|
29
|
+
export declare const DEFAULT_MAX_TOKENS = 10000;
|
|
25
30
|
export declare class LeavenDriver implements OnModuleInit, OnModuleDestroy {
|
|
26
31
|
private executor;
|
|
27
32
|
private schema;
|
|
28
33
|
private readonly options;
|
|
29
34
|
/** Maximum number of memoized query analyses retained */
|
|
30
35
|
private static readonly MAX_ANALYSIS_ENTRIES;
|
|
36
|
+
/**
|
|
37
|
+
* Estimated memory budget of the analysis memo: 8 MiB. An entry's cost is
|
|
38
|
+
* its key, which holds the whole query text (estimated at 2 bytes per
|
|
39
|
+
* UTF-16 code unit plus a fixed 64 for the map slot and result), and an
|
|
40
|
+
* entry above a tenth of the budget is never memoized.
|
|
41
|
+
*/
|
|
42
|
+
static readonly MAX_ANALYSIS_BYTES: number;
|
|
31
43
|
/**
|
|
32
44
|
* LRU of {@link QueryAnalysis} keyed by query string and operation name.
|
|
33
45
|
* Cleared whenever the schema changes, since complexity is schema-dependent.
|
|
34
46
|
*/
|
|
35
47
|
private readonly analysisCache;
|
|
48
|
+
/** Estimated bytes held by {@link analysisCache} */
|
|
49
|
+
private analysisBytes;
|
|
36
50
|
constructor(options: LeavenModuleOptions);
|
|
37
51
|
/**
|
|
38
52
|
* Initialize the driver with a schema
|
|
@@ -55,6 +69,11 @@ export declare class LeavenDriver implements OnModuleInit, OnModuleDestroy {
|
|
|
55
69
|
* Get the current schema
|
|
56
70
|
*/
|
|
57
71
|
getSchema(): GraphQLSchema | null;
|
|
72
|
+
/**
|
|
73
|
+
* Effective parser options: the configured `parseOptions` with `maxTokens`
|
|
74
|
+
* defaulted to {@link DEFAULT_MAX_TOKENS}.
|
|
75
|
+
*/
|
|
76
|
+
getParseOptions(): ParseOptions;
|
|
58
77
|
/**
|
|
59
78
|
* Get the executor instance
|
|
60
79
|
*/
|
|
@@ -150,10 +169,15 @@ export declare class LeavenDriver implements OnModuleInit, OnModuleDestroy {
|
|
|
150
169
|
*/
|
|
151
170
|
private attachQueryAnalysis;
|
|
152
171
|
/**
|
|
153
|
-
* Store an analysis result, evicting
|
|
154
|
-
*
|
|
172
|
+
* Store an analysis result, evicting least recently used entries until
|
|
173
|
+
* both {@link MAX_ANALYSIS_ENTRIES} and {@link MAX_ANALYSIS_BYTES} hold.
|
|
174
|
+
* A key above a tenth of the byte budget is not memoized at all.
|
|
155
175
|
*/
|
|
156
176
|
private memoizeAnalysis;
|
|
177
|
+
/** Estimated bytes one memo entry retains. See {@link MAX_ANALYSIS_BYTES}. */
|
|
178
|
+
private static analysisEntryBytes;
|
|
179
|
+
/** Empty the analysis memo, keeping its byte count in step */
|
|
180
|
+
private clearAnalysisCache;
|
|
157
181
|
/**
|
|
158
182
|
* Record a fail-closed sentinel for both analysis fields and log the cause.
|
|
159
183
|
*
|
package/dist/driver.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAc,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,cAAc,
|
|
1
|
+
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAc,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,cAAc,EAKd,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EACV,mBAAmB,EACnB,UAAU,EACV,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC5D,IAAI,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAaD;;;;;GAKG;AACH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAS,CAAC;AAEzC,qBACa,YAAa,YAAW,YAAY,EAAE,eAAe;IAChE,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,M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C,EAAE,MAAM,GACrB,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAoC9E;;OAEG;IACU,aAAa,CACxB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,aAAa,CAAC;IAYzB;;;;;;;OAOG;YACW,gBAAgB;IA2D9B;;OAEG;YACW,aAAa;IAiB3B;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,OAAO,CAAC,mBAAmB;IA2D3B;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAoBvB,8EAA8E;IAC9E,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAIjC,8DAA8D;IAC9D,OAAO,CAAC,kBAAkB;IAK1B;;;;;;OAMG;IACH,OAAO,CAAC,qBAAqB;IAS7B;;OAEG;IACI,mBAAmB,IAAI,OAAO;IAOrC;;;;;;OAMG;IACI,sBAAsB,IAAI,OAAO;IAOxC;;OAEG;IACI,OAAO,IAAI,MAAM;IAIxB;;OAEG;IACI,aAAa,IAAI,UAAU,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,GAAG,IAAI;IAI1E;;;;;;OAMG;IACU,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAI1C"}
|
package/dist/graphql-driver.d.ts
CHANGED
|
@@ -28,6 +28,12 @@ export interface LeavenDriverConfig extends GqlModuleOptions {
|
|
|
28
28
|
maxComplexity?: number;
|
|
29
29
|
/** Maximum allowed query depth. Enforced by the executor at parse time. */
|
|
30
30
|
maxDepth?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Parser limits passed to the executor, in the core executor's
|
|
33
|
+
* `parseOptions` shape. `maxTokens` defaults to 10000; set it to
|
|
34
|
+
* `Infinity` to opt out.
|
|
35
|
+
*/
|
|
36
|
+
parseOptions?: ExecutorConfig['parseOptions'];
|
|
31
37
|
/** Serve GraphiQL on `GET <path>`. Defaults to `false`. */
|
|
32
38
|
playground?: boolean;
|
|
33
39
|
/** WebSocket endpoint advertised to GraphiQL, when subscriptions are served. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql-driver.d.ts","sourceRoot":"","sources":["../src/graphql-driver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAgB,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"graphql-driver.d.ts","sourceRoot":"","sources":["../src/graphql-driver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAgB,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAgD3E;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IAC1D,sEAAsE;IACtE,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IAChC,gFAAgF;IAChF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,YAAY,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IAC9C,2DAA2D;IAC3D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gFAAgF;IAChF,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,mEAAmE;IACnE,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,qBAAqB,CAAC;IACtE;;;OAGG;IACH,iCAAiC,CAAC,EAAE,OAAO,CAAC;CAC7C;AAoBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,mBAAoB,SAAQ,qBAAqB,CAAC,kBAAkB,CAAC;IAChF,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,OAAO,CAAmC;IAElD;;;;;;OAMG;IACU,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoC9D;;;;;;;OAOG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAOlC;;;OAGG;IACI,WAAW,IAAI,cAAc,GAAG,IAAI;IAI3C;;OAEG;YACW,eAAe;IAsE7B;;OAEG;IACH,OAAO,CAAC,eAAe;IASvB;;;;;;OAMG;YACW,YAAY;IAqB1B;;;;;;;;;OASG;IACH,OAAO,CAAC,OAAO;IAiCf;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,aAAa;IA2BrB;;;;;;;;OAQG;IACH,OAAO,CAAC,iBAAiB;IAezB;;;;;;OAMG;mBACkB,QAAQ;IAmB7B;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;CAoBpC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* Licensed under the Apache License, Version 2.0
|
|
26
26
|
*/
|
|
27
27
|
export { LeavenModule, LEAVEN_MODULE_OPTIONS, LEAVEN_DRIVER, LEAVEN_PUBSUB } from './module';
|
|
28
|
-
export { LeavenDriver, type HandlerResult } from './driver';
|
|
28
|
+
export { LeavenDriver, DEFAULT_MAX_TOKENS, type HandlerResult } from './driver';
|
|
29
29
|
export { LeavenGraphQLDriver, type LeavenDriverConfig } from './graphql-driver';
|
|
30
30
|
export type { LeavenModuleOptions, LeavenModuleAsyncOptions, LeavenModuleFactoryAsyncOptions, LeavenModuleClassAsyncOptions, LeavenModuleExistingAsyncOptions, LeavenOptionsFactory, BuildSchemaOptions, DirectiveDefinition, ContextFactory, FormatErrorFn, GraphQLFormattedError,
|
|
31
31
|
/** @deprecated Has no effect; removal target 0.3.0. */
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG7F,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG7F,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAIhF,OAAO,EAAE,mBAAmB,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGhF,YAAY,EACV,mBAAmB,EACnB,wBAAwB,EACxB,+BAA+B,EAC/B,6BAA6B,EAC7B,gCAAgC,EAChC,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,qBAAqB;AACrB,uDAAuD;AACvD,YAAY;AACZ,uDAAuD;AACvD,aAAa,EACb,WAAW,EACX,UAAU,EACV,mBAAmB,IAAI,4BAA4B,GACpD,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,UAAU,EACV,UAAU,EACV,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,UAAU,EACV,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,eAAe,EACf,SAAS,EACT,uBAAuB,EACvB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,MAAM,EACN,KAAK,EACL,WAAW,EACX,aAAa,EACb,SAAS,EACT,eAAe,EACf,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,KAAK,cAAc,GACpB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAG1E,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,UAAU,EACV,UAAU,GACX,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,EACrB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,aAAa,GACnB,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -391,15 +391,20 @@ import {
|
|
|
391
391
|
import {
|
|
392
392
|
LeavenExecutor,
|
|
393
393
|
calculateQueryDepth,
|
|
394
|
-
compileQuery
|
|
394
|
+
compileQuery,
|
|
395
|
+
escapeLog
|
|
395
396
|
} from "@leaven-graphql/core";
|
|
396
397
|
import { ValidationError, formatError, isLeavenError } from "@leaven-graphql/errors";
|
|
398
|
+
var DEFAULT_MAX_TOKENS = 1e4;
|
|
399
|
+
|
|
397
400
|
class LeavenDriver {
|
|
398
401
|
executor = null;
|
|
399
402
|
schema = null;
|
|
400
403
|
options;
|
|
401
404
|
static MAX_ANALYSIS_ENTRIES = 1000;
|
|
405
|
+
static MAX_ANALYSIS_BYTES = 8 * 1024 * 1024;
|
|
402
406
|
analysisCache = new Map;
|
|
407
|
+
analysisBytes = 0;
|
|
403
408
|
constructor(options) {
|
|
404
409
|
this.options = options;
|
|
405
410
|
}
|
|
@@ -414,7 +419,7 @@ class LeavenDriver {
|
|
|
414
419
|
await this.executor.clearCaches();
|
|
415
420
|
this.executor = null;
|
|
416
421
|
}
|
|
417
|
-
this.
|
|
422
|
+
this.clearAnalysisCache();
|
|
418
423
|
}
|
|
419
424
|
setSchema(schema) {
|
|
420
425
|
this.schema = schema;
|
|
@@ -423,6 +428,12 @@ class LeavenDriver {
|
|
|
423
428
|
getSchema() {
|
|
424
429
|
return this.schema;
|
|
425
430
|
}
|
|
431
|
+
getParseOptions() {
|
|
432
|
+
return {
|
|
433
|
+
...this.options.parseOptions,
|
|
434
|
+
maxTokens: this.options.parseOptions?.maxTokens ?? DEFAULT_MAX_TOKENS
|
|
435
|
+
};
|
|
436
|
+
}
|
|
426
437
|
getExecutor() {
|
|
427
438
|
return this.executor;
|
|
428
439
|
}
|
|
@@ -436,9 +447,10 @@ class LeavenDriver {
|
|
|
436
447
|
metrics: this.options.metrics,
|
|
437
448
|
maxComplexity: this.options.maxComplexity,
|
|
438
449
|
maxDepth: this.options.maxDepth,
|
|
450
|
+
parseOptions: this.getParseOptions(),
|
|
439
451
|
introspection: this.isIntrospectionEnabled()
|
|
440
452
|
};
|
|
441
|
-
this.
|
|
453
|
+
this.clearAnalysisCache();
|
|
442
454
|
this.executor = new LeavenExecutor(config);
|
|
443
455
|
}
|
|
444
456
|
async execute(query, variables, context, operationName) {
|
|
@@ -532,7 +544,7 @@ class LeavenDriver {
|
|
|
532
544
|
}
|
|
533
545
|
return { query };
|
|
534
546
|
}
|
|
535
|
-
throw new ValidationError(`Unsupported content type "${contentType
|
|
547
|
+
throw new ValidationError(`Unsupported content type "${contentType ? escapeLog(contentType, 64) : "(none)"}": ` + "use application/json or application/graphql");
|
|
536
548
|
}
|
|
537
549
|
const url = new URL(request.url);
|
|
538
550
|
const query = url.searchParams.get("query");
|
|
@@ -582,7 +594,8 @@ class LeavenDriver {
|
|
|
582
594
|
}
|
|
583
595
|
let document;
|
|
584
596
|
try {
|
|
585
|
-
|
|
597
|
+
const { graphqlOptions, maxTokens } = this.getParseOptions();
|
|
598
|
+
document = typeof query === "string" ? parse(query, { ...graphqlOptions, maxTokens }) : query;
|
|
586
599
|
} catch (error) {
|
|
587
600
|
if (error instanceof GraphQLError) {
|
|
588
601
|
return;
|
|
@@ -606,13 +619,26 @@ class LeavenDriver {
|
|
|
606
619
|
}
|
|
607
620
|
}
|
|
608
621
|
memoizeAnalysis(key, analysis) {
|
|
609
|
-
|
|
622
|
+
const bytes = LeavenDriver.analysisEntryBytes(key);
|
|
623
|
+
if (bytes > LeavenDriver.MAX_ANALYSIS_BYTES / 10)
|
|
624
|
+
return;
|
|
625
|
+
if (this.analysisCache.delete(key)) {
|
|
626
|
+
this.analysisBytes -= bytes;
|
|
627
|
+
}
|
|
628
|
+
while (this.analysisCache.size > 0 && (this.analysisCache.size >= LeavenDriver.MAX_ANALYSIS_ENTRIES || this.analysisBytes + bytes > LeavenDriver.MAX_ANALYSIS_BYTES)) {
|
|
610
629
|
const oldest = this.analysisCache.keys().next().value;
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
}
|
|
630
|
+
this.analysisCache.delete(oldest);
|
|
631
|
+
this.analysisBytes -= LeavenDriver.analysisEntryBytes(oldest);
|
|
614
632
|
}
|
|
615
633
|
this.analysisCache.set(key, analysis);
|
|
634
|
+
this.analysisBytes += bytes;
|
|
635
|
+
}
|
|
636
|
+
static analysisEntryBytes(key) {
|
|
637
|
+
return key.length * 2 + 64;
|
|
638
|
+
}
|
|
639
|
+
clearAnalysisCache() {
|
|
640
|
+
this.analysisCache.clear();
|
|
641
|
+
this.analysisBytes = 0;
|
|
616
642
|
}
|
|
617
643
|
recordAnalysisFailure(target, error) {
|
|
618
644
|
console.error("[Leaven] Query analysis failed; failing closed:", error);
|
|
@@ -638,7 +664,7 @@ class LeavenDriver {
|
|
|
638
664
|
return this.executor?.getCacheStats() ?? null;
|
|
639
665
|
}
|
|
640
666
|
async clearCaches() {
|
|
641
|
-
this.
|
|
667
|
+
this.clearAnalysisCache();
|
|
642
668
|
await this.executor?.clearCaches();
|
|
643
669
|
}
|
|
644
670
|
}
|
|
@@ -1105,6 +1131,8 @@ import {
|
|
|
1105
1131
|
SetMetadata as SetMetadata3
|
|
1106
1132
|
} from "@nestjs/common";
|
|
1107
1133
|
import { parse as parse3, getOperationAST } from "graphql";
|
|
1134
|
+
import { escapeLog as escapeLog2 } from "@leaven-graphql/core";
|
|
1135
|
+
import { isValidOperationId } from "@leaven-graphql/ws";
|
|
1108
1136
|
var SOCKET_OPEN = 1;
|
|
1109
1137
|
var ITERATOR_TEARDOWN_TIMEOUT_MS = 1000;
|
|
1110
1138
|
|
|
@@ -1174,6 +1202,7 @@ class SubscriptionManager {
|
|
|
1174
1202
|
request,
|
|
1175
1203
|
subscriptions: new Map,
|
|
1176
1204
|
initialized: false,
|
|
1205
|
+
initializing: false,
|
|
1177
1206
|
connectionParams: undefined,
|
|
1178
1207
|
context: undefined,
|
|
1179
1208
|
keepAliveInterval: undefined,
|
|
@@ -1199,6 +1228,11 @@ class SubscriptionManager {
|
|
|
1199
1228
|
socket.close(4400, "Bad Request");
|
|
1200
1229
|
return;
|
|
1201
1230
|
}
|
|
1231
|
+
const { type, id } = parsed;
|
|
1232
|
+
if ((type === "subscribe" || type === "complete") && !isValidOperationId(id)) {
|
|
1233
|
+
socket.close(4400, "Invalid message");
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1202
1236
|
message = parsed;
|
|
1203
1237
|
} catch (error) {
|
|
1204
1238
|
console.error("Error parsing WebSocket message:", error);
|
|
@@ -1237,10 +1271,11 @@ class SubscriptionManager {
|
|
|
1237
1271
|
}
|
|
1238
1272
|
}
|
|
1239
1273
|
async handleConnectionInit(socket, state, message) {
|
|
1240
|
-
if (state.initialized) {
|
|
1274
|
+
if (state.initialized || state.initializing) {
|
|
1241
1275
|
socket.close(4429, "Too many initialization requests");
|
|
1242
1276
|
return;
|
|
1243
1277
|
}
|
|
1278
|
+
state.initializing = true;
|
|
1244
1279
|
state.connectionParams = message.payload ?? {};
|
|
1245
1280
|
const ctx = {
|
|
1246
1281
|
socket,
|
|
@@ -1249,6 +1284,9 @@ class SubscriptionManager {
|
|
|
1249
1284
|
};
|
|
1250
1285
|
if (this.config.onConnect) {
|
|
1251
1286
|
const allowed = await this.config.onConnect(ctx);
|
|
1287
|
+
if (this.connections.get(socket) !== state) {
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1252
1290
|
if (!allowed) {
|
|
1253
1291
|
socket.close(4401, "Unauthorized");
|
|
1254
1292
|
return;
|
|
@@ -1262,6 +1300,9 @@ class SubscriptionManager {
|
|
|
1262
1300
|
}
|
|
1263
1301
|
this.send(socket, { type: "connection_ack" });
|
|
1264
1302
|
if (this.config.keepAlive) {
|
|
1303
|
+
if (state.keepAliveInterval) {
|
|
1304
|
+
clearInterval(state.keepAliveInterval);
|
|
1305
|
+
}
|
|
1265
1306
|
state.keepAliveInterval = setInterval(() => {
|
|
1266
1307
|
this.send(socket, { type: "ping" });
|
|
1267
1308
|
}, this.config.keepAlive);
|
|
@@ -1356,7 +1397,7 @@ class SubscriptionManager {
|
|
|
1356
1397
|
}
|
|
1357
1398
|
registration.iterator = iterator;
|
|
1358
1399
|
this.pumpStream(socket, state, id, registration, iterator).catch((error) => {
|
|
1359
|
-
console.error(`Subscription pump failed for operation ${id}:`, error);
|
|
1400
|
+
console.error(`Subscription pump failed for operation ${escapeLog2(id)}:`, error);
|
|
1360
1401
|
state.subscriptions.delete(id);
|
|
1361
1402
|
});
|
|
1362
1403
|
}
|
|
@@ -1405,7 +1446,8 @@ class SubscriptionManager {
|
|
|
1405
1446
|
}
|
|
1406
1447
|
isSubscriptionOperation(query, operationName) {
|
|
1407
1448
|
try {
|
|
1408
|
-
const
|
|
1449
|
+
const { graphqlOptions, maxTokens } = this.driver.getParseOptions();
|
|
1450
|
+
const document = parse3(query, { ...graphqlOptions, maxTokens });
|
|
1409
1451
|
return getOperationAST(document, operationName)?.operation === "subscription";
|
|
1410
1452
|
} catch {
|
|
1411
1453
|
return false;
|
|
@@ -1704,6 +1746,10 @@ class LeavenGraphQLDriver extends AbstractGraphQLDriver {
|
|
|
1704
1746
|
metrics: options.metrics,
|
|
1705
1747
|
maxComplexity: options.maxComplexity,
|
|
1706
1748
|
maxDepth: options.maxDepth,
|
|
1749
|
+
parseOptions: {
|
|
1750
|
+
...options.parseOptions,
|
|
1751
|
+
maxTokens: options.parseOptions?.maxTokens ?? DEFAULT_MAX_TOKENS
|
|
1752
|
+
},
|
|
1707
1753
|
introspection: options.introspection ?? true,
|
|
1708
1754
|
formatExecutionError: LeavenGraphQLDriver.formatExecutionError
|
|
1709
1755
|
});
|
|
@@ -2057,6 +2103,7 @@ export {
|
|
|
2057
2103
|
ComplexityGuard,
|
|
2058
2104
|
ComplexityInterceptor,
|
|
2059
2105
|
Context,
|
|
2106
|
+
DEFAULT_MAX_TOKENS,
|
|
2060
2107
|
DEPRECATED_KEY,
|
|
2061
2108
|
DESCRIPTION_KEY,
|
|
2062
2109
|
Decorators,
|
package/dist/subscriptions.d.ts
CHANGED
|
@@ -375,7 +375,10 @@ export declare class SubscriptionManager implements OnModuleInit, OnModuleDestro
|
|
|
375
375
|
* Determine whether a query string is a streaming `subscription` operation.
|
|
376
376
|
*
|
|
377
377
|
* Parse failures return `false` so that syntax errors surface through the
|
|
378
|
-
* normal execution/error path instead of being masked here.
|
|
378
|
+
* normal execution/error path instead of being masked here. That includes
|
|
379
|
+
* an exceeded `parseOptions.maxTokens`: the parse here applies the same
|
|
380
|
+
* token budget as the executor (default 10000), so an oversized document is
|
|
381
|
+
* never lexed in full, and the executor then reports the limit.
|
|
379
382
|
*/
|
|
380
383
|
private isSubscriptionOperation;
|
|
381
384
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptions.d.ts","sourceRoot":"","sources":["../src/subscriptions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"subscriptions.d.ts","sourceRoot":"","sources":["../src/subscriptions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAG3C,OAAO,EAAE,YAAY,EAAsB,MAAM,UAAU,CAAC;AAE5D,OAAO,EAIL,KAAK,mBAAmB,EACxB,KAAK,UAAU,EAChB,MAAM,SAAS,CAAC;AAiCjB;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IACjC,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,8EAA8E;IAC9E,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,E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AkB5B;;;;;;;;;;;;;OAaG;IACU,WAAW,CAAC,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiC/D;;OAEG;IACH,OAAO,CAAC,WAAW;IASnB;;OAEG;IACH,OAAO,CAAC,IAAI;IAMZ;;OAEG;IACH,OAAO,CAAC,SAAS;IAQjB;;;;;;;;;;;;;;;;;;;OAmBG;IACI,oBAAoB,CACzB,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,UAAU,GACnB,OAAO;IAgBV;;;;;;;;;;;;OAYG;IACI,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAc5D;;;;;;;;;;;;;;;OAeG;IACI,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAIrD;;OAEG;IACI,kBAAkB,IAAI,MAAM;IAInC;;OAEG;IACI,oBAAoB,IAAI,MAAM;CAOtC;AAwDD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,OAAO,EACtB,OAAO,CAAC,EAAE;IACR,MAAM,CAAC,EAAE,CACP,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,OAAO,KACb,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACjC,GACA,eAAe,CAuBjB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,IAAI,kBAAkB,CAEjD"}
|
package/dist/types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import type { Type } from '@nestjs/common';
|
|
8
8
|
import type { ModuleMetadata } from '@nestjs/common/interfaces';
|
|
9
9
|
import type { GraphQLSchema, DocumentNode } from 'graphql';
|
|
10
|
-
import type { DocumentCacheConfig } from '@leaven-graphql/core';
|
|
10
|
+
import type { DocumentCacheConfig, ParseOptions } from '@leaven-graphql/core';
|
|
11
11
|
import type { PubSub } from '@leaven-graphql/ws';
|
|
12
12
|
import type { SubscriptionConfig } from './subscriptions';
|
|
13
13
|
/**
|
|
@@ -111,6 +111,19 @@ export interface LeavenModuleOptions {
|
|
|
111
111
|
* Maximum query depth allowed
|
|
112
112
|
*/
|
|
113
113
|
maxDepth?: number;
|
|
114
|
+
/**
|
|
115
|
+
* Parser limits, in the same shape as the core executor's `parseOptions`.
|
|
116
|
+
*
|
|
117
|
+
* Applied everywhere the module parses a document: the executor (HTTP and
|
|
118
|
+
* subscription transports alike), query analysis for the complexity/depth
|
|
119
|
+
* guards, and the subscription transport's synchronous operation-type
|
|
120
|
+
* detection. A document over a limit is rejected through the executor's
|
|
121
|
+
* normal error response.
|
|
122
|
+
*
|
|
123
|
+
* `maxTokens` defaults to 10000; set it to `Infinity` to opt out.
|
|
124
|
+
* `maxDepth` here is overridden by the top-level `maxDepth` when both are set.
|
|
125
|
+
*/
|
|
126
|
+
parseOptions?: ParseOptions;
|
|
114
127
|
/**
|
|
115
128
|
* Enable execution metrics
|
|
116
129
|
* @default false
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,g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AAC,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACnC,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACnC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,UAAU,CAAC,QAAQ,GAAG,OAAO,EAAE,SAAS,GAAG,QAAQ;IAClE,GAAG,EAAE,QAAQ,CAAC;IACd,GAAG,EAAE,SAAS,CAAC;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,CAAC,GAAG,UAAU,KAAK,CAAC,CAAC;IAChC,OAAO,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC,CAAC;IAC1B,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1C,OAAO,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC,CAAC;CAC3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leaven-graphql/nestjs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "NestJS integration for Leaven GraphQL",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@graphql-tools/schema": "^10.1.0",
|
|
23
23
|
"@leaven-graphql/context": "0.2.1",
|
|
24
|
-
"@leaven-graphql/core": "0.2.
|
|
24
|
+
"@leaven-graphql/core": "0.2.3",
|
|
25
25
|
"@leaven-graphql/errors": "0.2.1",
|
|
26
|
-
"@leaven-graphql/playground": "0.2.
|
|
27
|
-
"@leaven-graphql/ws": "0.2.
|
|
26
|
+
"@leaven-graphql/playground": "0.2.2",
|
|
27
|
+
"@leaven-graphql/ws": "0.2.3"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@nestjs/common": ">=10.0.0",
|