@leaven-graphql/plugins 0.2.0 → 0.2.2
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/dist/index.js +10 -401
- package/package.json +12 -7
package/dist/index.js
CHANGED
|
@@ -251,400 +251,9 @@ class PluginManager {
|
|
|
251
251
|
function createPluginManager(config) {
|
|
252
252
|
return new PluginManager(config);
|
|
253
253
|
}
|
|
254
|
-
// ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/jsutils/invariant.mjs
|
|
255
|
-
function invariant(condition, message) {
|
|
256
|
-
const booleanCondition = Boolean(condition);
|
|
257
|
-
if (!booleanCondition) {
|
|
258
|
-
throw new Error(message != null ? message : "Unexpected invariant triggered.");
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/location.mjs
|
|
263
|
-
var LineRegExp = /\r\n|[\n\r]/g;
|
|
264
|
-
function getLocation(source, position) {
|
|
265
|
-
let lastLineStart = 0;
|
|
266
|
-
let line = 1;
|
|
267
|
-
for (const match of source.body.matchAll(LineRegExp)) {
|
|
268
|
-
typeof match.index === "number" || invariant(false);
|
|
269
|
-
if (match.index >= position) {
|
|
270
|
-
break;
|
|
271
|
-
}
|
|
272
|
-
lastLineStart = match.index + match[0].length;
|
|
273
|
-
line += 1;
|
|
274
|
-
}
|
|
275
|
-
return {
|
|
276
|
-
line,
|
|
277
|
-
column: position + 1 - lastLineStart
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/printLocation.mjs
|
|
282
|
-
function printLocation(location) {
|
|
283
|
-
return printSourceLocation(location.source, getLocation(location.source, location.start));
|
|
284
|
-
}
|
|
285
|
-
function printSourceLocation(source, sourceLocation) {
|
|
286
|
-
const firstLineColumnOffset = source.locationOffset.column - 1;
|
|
287
|
-
const body = "".padStart(firstLineColumnOffset) + source.body;
|
|
288
|
-
const lineIndex = sourceLocation.line - 1;
|
|
289
|
-
const lineOffset = source.locationOffset.line - 1;
|
|
290
|
-
const lineNum = sourceLocation.line + lineOffset;
|
|
291
|
-
const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0;
|
|
292
|
-
const columnNum = sourceLocation.column + columnOffset;
|
|
293
|
-
const locationStr = `${source.name}:${lineNum}:${columnNum}
|
|
294
|
-
`;
|
|
295
|
-
const lines = body.split(/\r\n|[\n\r]/g);
|
|
296
|
-
const locationLine = lines[lineIndex];
|
|
297
|
-
if (locationLine.length > 120) {
|
|
298
|
-
const subLineIndex = Math.floor(columnNum / 80);
|
|
299
|
-
const subLineColumnNum = columnNum % 80;
|
|
300
|
-
const subLines = [];
|
|
301
|
-
for (let i = 0;i < locationLine.length; i += 80) {
|
|
302
|
-
subLines.push(locationLine.slice(i, i + 80));
|
|
303
|
-
}
|
|
304
|
-
return locationStr + printPrefixedLines([
|
|
305
|
-
[`${lineNum} |`, subLines[0]],
|
|
306
|
-
...subLines.slice(1, subLineIndex + 1).map((subLine) => ["|", subLine]),
|
|
307
|
-
["|", "^".padStart(subLineColumnNum)],
|
|
308
|
-
["|", subLines[subLineIndex + 1]]
|
|
309
|
-
]);
|
|
310
|
-
}
|
|
311
|
-
return locationStr + printPrefixedLines([
|
|
312
|
-
[`${lineNum - 1} |`, lines[lineIndex - 1]],
|
|
313
|
-
[`${lineNum} |`, locationLine],
|
|
314
|
-
["|", "^".padStart(columnNum)],
|
|
315
|
-
[`${lineNum + 1} |`, lines[lineIndex + 1]]
|
|
316
|
-
]);
|
|
317
|
-
}
|
|
318
|
-
function printPrefixedLines(lines) {
|
|
319
|
-
const existingLines = lines.filter(([_, line]) => line !== undefined);
|
|
320
|
-
const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));
|
|
321
|
-
return existingLines.map(([prefix, line]) => prefix.padStart(padLen) + (line ? " " + line : "")).join(`
|
|
322
|
-
`);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
// ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/language/kinds.mjs
|
|
326
|
-
var Kind;
|
|
327
|
-
(function(Kind2) {
|
|
328
|
-
Kind2["NAME"] = "Name";
|
|
329
|
-
Kind2["DOCUMENT"] = "Document";
|
|
330
|
-
Kind2["OPERATION_DEFINITION"] = "OperationDefinition";
|
|
331
|
-
Kind2["VARIABLE_DEFINITION"] = "VariableDefinition";
|
|
332
|
-
Kind2["SELECTION_SET"] = "SelectionSet";
|
|
333
|
-
Kind2["FIELD"] = "Field";
|
|
334
|
-
Kind2["ARGUMENT"] = "Argument";
|
|
335
|
-
Kind2["FRAGMENT_SPREAD"] = "FragmentSpread";
|
|
336
|
-
Kind2["INLINE_FRAGMENT"] = "InlineFragment";
|
|
337
|
-
Kind2["FRAGMENT_DEFINITION"] = "FragmentDefinition";
|
|
338
|
-
Kind2["VARIABLE"] = "Variable";
|
|
339
|
-
Kind2["INT"] = "IntValue";
|
|
340
|
-
Kind2["FLOAT"] = "FloatValue";
|
|
341
|
-
Kind2["STRING"] = "StringValue";
|
|
342
|
-
Kind2["BOOLEAN"] = "BooleanValue";
|
|
343
|
-
Kind2["NULL"] = "NullValue";
|
|
344
|
-
Kind2["ENUM"] = "EnumValue";
|
|
345
|
-
Kind2["LIST"] = "ListValue";
|
|
346
|
-
Kind2["OBJECT"] = "ObjectValue";
|
|
347
|
-
Kind2["OBJECT_FIELD"] = "ObjectField";
|
|
348
|
-
Kind2["DIRECTIVE"] = "Directive";
|
|
349
|
-
Kind2["NAMED_TYPE"] = "NamedType";
|
|
350
|
-
Kind2["LIST_TYPE"] = "ListType";
|
|
351
|
-
Kind2["NON_NULL_TYPE"] = "NonNullType";
|
|
352
|
-
Kind2["SCHEMA_DEFINITION"] = "SchemaDefinition";
|
|
353
|
-
Kind2["OPERATION_TYPE_DEFINITION"] = "OperationTypeDefinition";
|
|
354
|
-
Kind2["SCALAR_TYPE_DEFINITION"] = "ScalarTypeDefinition";
|
|
355
|
-
Kind2["OBJECT_TYPE_DEFINITION"] = "ObjectTypeDefinition";
|
|
356
|
-
Kind2["FIELD_DEFINITION"] = "FieldDefinition";
|
|
357
|
-
Kind2["INPUT_VALUE_DEFINITION"] = "InputValueDefinition";
|
|
358
|
-
Kind2["INTERFACE_TYPE_DEFINITION"] = "InterfaceTypeDefinition";
|
|
359
|
-
Kind2["UNION_TYPE_DEFINITION"] = "UnionTypeDefinition";
|
|
360
|
-
Kind2["ENUM_TYPE_DEFINITION"] = "EnumTypeDefinition";
|
|
361
|
-
Kind2["ENUM_VALUE_DEFINITION"] = "EnumValueDefinition";
|
|
362
|
-
Kind2["INPUT_OBJECT_TYPE_DEFINITION"] = "InputObjectTypeDefinition";
|
|
363
|
-
Kind2["DIRECTIVE_DEFINITION"] = "DirectiveDefinition";
|
|
364
|
-
Kind2["SCHEMA_EXTENSION"] = "SchemaExtension";
|
|
365
|
-
Kind2["SCALAR_TYPE_EXTENSION"] = "ScalarTypeExtension";
|
|
366
|
-
Kind2["OBJECT_TYPE_EXTENSION"] = "ObjectTypeExtension";
|
|
367
|
-
Kind2["INTERFACE_TYPE_EXTENSION"] = "InterfaceTypeExtension";
|
|
368
|
-
Kind2["UNION_TYPE_EXTENSION"] = "UnionTypeExtension";
|
|
369
|
-
Kind2["ENUM_TYPE_EXTENSION"] = "EnumTypeExtension";
|
|
370
|
-
Kind2["INPUT_OBJECT_TYPE_EXTENSION"] = "InputObjectTypeExtension";
|
|
371
|
-
Kind2["TYPE_COORDINATE"] = "TypeCoordinate";
|
|
372
|
-
Kind2["MEMBER_COORDINATE"] = "MemberCoordinate";
|
|
373
|
-
Kind2["ARGUMENT_COORDINATE"] = "ArgumentCoordinate";
|
|
374
|
-
Kind2["DIRECTIVE_COORDINATE"] = "DirectiveCoordinate";
|
|
375
|
-
Kind2["DIRECTIVE_ARGUMENT_COORDINATE"] = "DirectiveArgumentCoordinate";
|
|
376
|
-
})(Kind || (Kind = {}));
|
|
377
|
-
// ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/jsutils/isObjectLike.mjs
|
|
378
|
-
function isObjectLike(value) {
|
|
379
|
-
return typeof value == "object" && value !== null;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
// ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/error/GraphQLError.mjs
|
|
383
|
-
function toNormalizedOptions(args) {
|
|
384
|
-
const firstArg = args[0];
|
|
385
|
-
if (firstArg == null || "kind" in firstArg || "length" in firstArg) {
|
|
386
|
-
return {
|
|
387
|
-
nodes: firstArg,
|
|
388
|
-
source: args[1],
|
|
389
|
-
positions: args[2],
|
|
390
|
-
path: args[3],
|
|
391
|
-
originalError: args[4],
|
|
392
|
-
extensions: args[5]
|
|
393
|
-
};
|
|
394
|
-
}
|
|
395
|
-
return firstArg;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
class GraphQLError extends Error {
|
|
399
|
-
constructor(message, ...rawArgs) {
|
|
400
|
-
var _this$nodes, _nodeLocations$, _ref;
|
|
401
|
-
const { nodes, source, positions, path, originalError, extensions } = toNormalizedOptions(rawArgs);
|
|
402
|
-
super(message);
|
|
403
|
-
this.name = "GraphQLError";
|
|
404
|
-
this.path = path !== null && path !== undefined ? path : undefined;
|
|
405
|
-
this.originalError = originalError !== null && originalError !== undefined ? originalError : undefined;
|
|
406
|
-
this.nodes = undefinedIfEmpty(Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined);
|
|
407
|
-
const nodeLocations = undefinedIfEmpty((_this$nodes = this.nodes) === null || _this$nodes === undefined ? undefined : _this$nodes.map((node) => node.loc).filter((loc) => loc != null));
|
|
408
|
-
this.source = source !== null && source !== undefined ? source : nodeLocations === null || nodeLocations === undefined ? undefined : (_nodeLocations$ = nodeLocations[0]) === null || _nodeLocations$ === undefined ? undefined : _nodeLocations$.source;
|
|
409
|
-
this.positions = positions !== null && positions !== undefined ? positions : nodeLocations === null || nodeLocations === undefined ? undefined : nodeLocations.map((loc) => loc.start);
|
|
410
|
-
this.locations = positions && source ? positions.map((pos) => getLocation(source, pos)) : nodeLocations === null || nodeLocations === undefined ? undefined : nodeLocations.map((loc) => getLocation(loc.source, loc.start));
|
|
411
|
-
const originalExtensions = isObjectLike(originalError === null || originalError === undefined ? undefined : originalError.extensions) ? originalError === null || originalError === undefined ? undefined : originalError.extensions : undefined;
|
|
412
|
-
this.extensions = (_ref = extensions !== null && extensions !== undefined ? extensions : originalExtensions) !== null && _ref !== undefined ? _ref : Object.create(null);
|
|
413
|
-
Object.defineProperties(this, {
|
|
414
|
-
message: {
|
|
415
|
-
writable: true,
|
|
416
|
-
enumerable: true
|
|
417
|
-
},
|
|
418
|
-
name: {
|
|
419
|
-
enumerable: false
|
|
420
|
-
},
|
|
421
|
-
nodes: {
|
|
422
|
-
enumerable: false
|
|
423
|
-
},
|
|
424
|
-
source: {
|
|
425
|
-
enumerable: false
|
|
426
|
-
},
|
|
427
|
-
positions: {
|
|
428
|
-
enumerable: false
|
|
429
|
-
},
|
|
430
|
-
originalError: {
|
|
431
|
-
enumerable: false
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
if (originalError !== null && originalError !== undefined && originalError.stack) {
|
|
435
|
-
Object.defineProperty(this, "stack", {
|
|
436
|
-
value: originalError.stack,
|
|
437
|
-
writable: true,
|
|
438
|
-
configurable: true
|
|
439
|
-
});
|
|
440
|
-
} else if (Error.captureStackTrace) {
|
|
441
|
-
Error.captureStackTrace(this, GraphQLError);
|
|
442
|
-
} else {
|
|
443
|
-
Object.defineProperty(this, "stack", {
|
|
444
|
-
value: Error().stack,
|
|
445
|
-
writable: true,
|
|
446
|
-
configurable: true
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
get [Symbol.toStringTag]() {
|
|
451
|
-
return "GraphQLError";
|
|
452
|
-
}
|
|
453
|
-
toString() {
|
|
454
|
-
let output = this.message;
|
|
455
|
-
if (this.nodes) {
|
|
456
|
-
for (const node of this.nodes) {
|
|
457
|
-
if (node.loc) {
|
|
458
|
-
output += `
|
|
459
|
-
|
|
460
|
-
` + printLocation(node.loc);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
} else if (this.source && this.locations) {
|
|
464
|
-
for (const location of this.locations) {
|
|
465
|
-
output += `
|
|
466
|
-
|
|
467
|
-
` + printSourceLocation(this.source, location);
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
return output;
|
|
471
|
-
}
|
|
472
|
-
toJSON() {
|
|
473
|
-
const formattedError = {
|
|
474
|
-
message: this.message
|
|
475
|
-
};
|
|
476
|
-
if (this.locations != null) {
|
|
477
|
-
formattedError.locations = this.locations;
|
|
478
|
-
}
|
|
479
|
-
if (this.path != null) {
|
|
480
|
-
formattedError.path = this.path;
|
|
481
|
-
}
|
|
482
|
-
if (this.extensions != null && Object.keys(this.extensions).length > 0) {
|
|
483
|
-
formattedError.extensions = this.extensions;
|
|
484
|
-
}
|
|
485
|
-
return formattedError;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
function undefinedIfEmpty(array) {
|
|
489
|
-
return array === undefined || array.length === 0 ? undefined : array;
|
|
490
|
-
}
|
|
491
|
-
// ../errors/src/codes.ts
|
|
492
|
-
var ErrorCode;
|
|
493
|
-
((ErrorCode2) => {
|
|
494
|
-
ErrorCode2["INTERNAL_ERROR"] = "INTERNAL_ERROR";
|
|
495
|
-
ErrorCode2["BAD_REQUEST"] = "BAD_REQUEST";
|
|
496
|
-
ErrorCode2["PAYLOAD_TOO_LARGE"] = "PAYLOAD_TOO_LARGE";
|
|
497
|
-
ErrorCode2["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
498
|
-
ErrorCode2["PARSE_ERROR"] = "PARSE_ERROR";
|
|
499
|
-
ErrorCode2["UNAUTHENTICATED"] = "UNAUTHENTICATED";
|
|
500
|
-
ErrorCode2["FORBIDDEN"] = "FORBIDDEN";
|
|
501
|
-
ErrorCode2["NOT_FOUND"] = "NOT_FOUND";
|
|
502
|
-
ErrorCode2["ALREADY_EXISTS"] = "ALREADY_EXISTS";
|
|
503
|
-
ErrorCode2["RATE_LIMITED"] = "RATE_LIMITED";
|
|
504
|
-
ErrorCode2["COMPLEXITY_LIMIT"] = "COMPLEXITY_LIMIT";
|
|
505
|
-
ErrorCode2["DEPTH_LIMIT"] = "DEPTH_LIMIT";
|
|
506
|
-
ErrorCode2["PERSISTED_QUERY_NOT_FOUND"] = "PERSISTED_QUERY_NOT_FOUND";
|
|
507
|
-
ErrorCode2["PERSISTED_QUERY_INVALID"] = "PERSISTED_QUERY_INVALID";
|
|
508
|
-
ErrorCode2["INVALID_INPUT"] = "INVALID_INPUT";
|
|
509
|
-
ErrorCode2["MISSING_REQUIRED_FIELD"] = "MISSING_REQUIRED_FIELD";
|
|
510
|
-
})(ErrorCode ||= {});
|
|
511
|
-
var ERROR_CODES = {
|
|
512
|
-
["INTERNAL_ERROR" /* INTERNAL_ERROR */]: {
|
|
513
|
-
status: 500,
|
|
514
|
-
message: "An internal error occurred"
|
|
515
|
-
},
|
|
516
|
-
["BAD_REQUEST" /* BAD_REQUEST */]: {
|
|
517
|
-
status: 400,
|
|
518
|
-
message: "Bad request"
|
|
519
|
-
},
|
|
520
|
-
["PAYLOAD_TOO_LARGE" /* PAYLOAD_TOO_LARGE */]: {
|
|
521
|
-
status: 413,
|
|
522
|
-
message: "Request payload is too large"
|
|
523
|
-
},
|
|
524
|
-
["VALIDATION_ERROR" /* VALIDATION_ERROR */]: {
|
|
525
|
-
status: 400,
|
|
526
|
-
message: "Validation failed"
|
|
527
|
-
},
|
|
528
|
-
["PARSE_ERROR" /* PARSE_ERROR */]: {
|
|
529
|
-
status: 400,
|
|
530
|
-
message: "Failed to parse GraphQL query"
|
|
531
|
-
},
|
|
532
|
-
["UNAUTHENTICATED" /* UNAUTHENTICATED */]: {
|
|
533
|
-
status: 401,
|
|
534
|
-
message: "Authentication required"
|
|
535
|
-
},
|
|
536
|
-
["FORBIDDEN" /* FORBIDDEN */]: {
|
|
537
|
-
status: 403,
|
|
538
|
-
message: "Access denied"
|
|
539
|
-
},
|
|
540
|
-
["NOT_FOUND" /* NOT_FOUND */]: {
|
|
541
|
-
status: 404,
|
|
542
|
-
message: "Resource not found"
|
|
543
|
-
},
|
|
544
|
-
["ALREADY_EXISTS" /* ALREADY_EXISTS */]: {
|
|
545
|
-
status: 409,
|
|
546
|
-
message: "Resource already exists"
|
|
547
|
-
},
|
|
548
|
-
["RATE_LIMITED" /* RATE_LIMITED */]: {
|
|
549
|
-
status: 429,
|
|
550
|
-
message: "Rate limit exceeded"
|
|
551
|
-
},
|
|
552
|
-
["COMPLEXITY_LIMIT" /* COMPLEXITY_LIMIT */]: {
|
|
553
|
-
status: 400,
|
|
554
|
-
message: "Query complexity limit exceeded"
|
|
555
|
-
},
|
|
556
|
-
["DEPTH_LIMIT" /* DEPTH_LIMIT */]: {
|
|
557
|
-
status: 400,
|
|
558
|
-
message: "Query depth limit exceeded"
|
|
559
|
-
},
|
|
560
|
-
["PERSISTED_QUERY_NOT_FOUND" /* PERSISTED_QUERY_NOT_FOUND */]: {
|
|
561
|
-
status: 400,
|
|
562
|
-
message: "Persisted query not found"
|
|
563
|
-
},
|
|
564
|
-
["PERSISTED_QUERY_INVALID" /* PERSISTED_QUERY_INVALID */]: {
|
|
565
|
-
status: 400,
|
|
566
|
-
message: "Invalid persisted query"
|
|
567
|
-
},
|
|
568
|
-
["INVALID_INPUT" /* INVALID_INPUT */]: {
|
|
569
|
-
status: 400,
|
|
570
|
-
message: "Invalid input provided"
|
|
571
|
-
},
|
|
572
|
-
["MISSING_REQUIRED_FIELD" /* MISSING_REQUIRED_FIELD */]: {
|
|
573
|
-
status: 400,
|
|
574
|
-
message: "Required field is missing"
|
|
575
|
-
}
|
|
576
|
-
};
|
|
577
|
-
var ERROR_CODE_SET = new Set(Object.values(ErrorCode));
|
|
578
|
-
|
|
579
|
-
// ../errors/src/errors.ts
|
|
580
|
-
class LeavenError extends Error {
|
|
581
|
-
code;
|
|
582
|
-
statusCode;
|
|
583
|
-
extensions;
|
|
584
|
-
originalError;
|
|
585
|
-
constructor(message, code = "INTERNAL_ERROR" /* INTERNAL_ERROR */, options) {
|
|
586
|
-
super(message);
|
|
587
|
-
this.name = "LeavenError";
|
|
588
|
-
this.code = code;
|
|
589
|
-
this.statusCode = options?.statusCode ?? ERROR_CODES[code]?.status ?? 500;
|
|
590
|
-
this.extensions = {
|
|
591
|
-
...options?.extensions,
|
|
592
|
-
code
|
|
593
|
-
};
|
|
594
|
-
this.originalError = options?.originalError;
|
|
595
|
-
Error.captureStackTrace?.(this, this.constructor);
|
|
596
|
-
}
|
|
597
|
-
toGraphQLError() {
|
|
598
|
-
return new GraphQLError(this.message, {
|
|
599
|
-
extensions: this.extensions,
|
|
600
|
-
originalError: this
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
toJSON() {
|
|
604
|
-
return {
|
|
605
|
-
message: this.message,
|
|
606
|
-
code: this.code,
|
|
607
|
-
statusCode: this.statusCode,
|
|
608
|
-
extensions: this.extensions
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
class ComplexityError extends LeavenError {
|
|
613
|
-
complexity;
|
|
614
|
-
maxComplexity;
|
|
615
|
-
constructor(complexity, maxComplexity, options) {
|
|
616
|
-
super(`Query complexity of ${complexity} exceeds maximum allowed complexity of ${maxComplexity}`, "COMPLEXITY_LIMIT" /* COMPLEXITY_LIMIT */, {
|
|
617
|
-
statusCode: 400,
|
|
618
|
-
extensions: {
|
|
619
|
-
...options?.extensions,
|
|
620
|
-
complexity,
|
|
621
|
-
maxComplexity
|
|
622
|
-
}
|
|
623
|
-
});
|
|
624
|
-
this.name = "ComplexityError";
|
|
625
|
-
this.complexity = complexity;
|
|
626
|
-
this.maxComplexity = maxComplexity;
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
class DepthLimitError extends LeavenError {
|
|
631
|
-
depth;
|
|
632
|
-
maxDepth;
|
|
633
|
-
constructor(depth, maxDepth, options) {
|
|
634
|
-
super(`Query depth of ${depth} exceeds maximum allowed depth of ${maxDepth}`, "DEPTH_LIMIT" /* DEPTH_LIMIT */, {
|
|
635
|
-
statusCode: 400,
|
|
636
|
-
extensions: {
|
|
637
|
-
...options?.extensions,
|
|
638
|
-
depth,
|
|
639
|
-
maxDepth
|
|
640
|
-
}
|
|
641
|
-
});
|
|
642
|
-
this.name = "DepthLimitError";
|
|
643
|
-
this.depth = depth;
|
|
644
|
-
this.maxDepth = maxDepth;
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
254
|
// src/builtin.ts
|
|
255
|
+
import { Kind } from "graphql";
|
|
256
|
+
import { ComplexityError, DepthLimitError } from "@leaven-graphql/errors";
|
|
648
257
|
function createPlugin(metadata, hooks) {
|
|
649
258
|
return {
|
|
650
259
|
metadata,
|
|
@@ -1180,13 +789,13 @@ function createComplexityPlugin(options) {
|
|
|
1180
789
|
};
|
|
1181
790
|
}
|
|
1182
791
|
export {
|
|
1183
|
-
|
|
1184
|
-
createPluginManager,
|
|
1185
|
-
createPlugin,
|
|
1186
|
-
createLoggingPlugin,
|
|
1187
|
-
createDepthLimitPlugin,
|
|
1188
|
-
createComplexityPlugin,
|
|
1189
|
-
createCachingPlugin,
|
|
792
|
+
PluginManager,
|
|
1190
793
|
composePlugins,
|
|
1191
|
-
|
|
794
|
+
createCachingPlugin,
|
|
795
|
+
createComplexityPlugin,
|
|
796
|
+
createDepthLimitPlugin,
|
|
797
|
+
createLoggingPlugin,
|
|
798
|
+
createPlugin,
|
|
799
|
+
createPluginManager,
|
|
800
|
+
createTracingPlugin
|
|
1192
801
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leaven-graphql/plugins",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Plugin system for Leaven GraphQL",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,20 +25,25 @@
|
|
|
25
25
|
],
|
|
26
26
|
"author": "Joseph Quinn",
|
|
27
27
|
"license": "Apache-2.0",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/quinnjr/leaven.git",
|
|
31
|
+
"directory": "packages/plugins"
|
|
32
|
+
},
|
|
28
33
|
"dependencies": {
|
|
29
|
-
"graphql": "
|
|
30
|
-
"@leaven-graphql/
|
|
31
|
-
"@leaven-graphql/errors": "0.2.0"
|
|
34
|
+
"@leaven-graphql/core": "0.2.2",
|
|
35
|
+
"@leaven-graphql/errors": "0.2.1"
|
|
32
36
|
},
|
|
33
37
|
"devDependencies": {
|
|
34
|
-
"@types/bun": "^1.3.
|
|
35
|
-
"
|
|
38
|
+
"@types/bun": "^1.3.14",
|
|
39
|
+
"graphql": "^16.8.0",
|
|
40
|
+
"typescript": "^6.0.0"
|
|
36
41
|
},
|
|
37
42
|
"peerDependencies": {
|
|
38
43
|
"graphql": "^16.0.0"
|
|
39
44
|
},
|
|
40
45
|
"scripts": {
|
|
41
|
-
"build": "bun build ./src/index.ts --outdir ./dist --target bun && tsc -p tsconfig.build.json",
|
|
46
|
+
"build": "bun build ./src/index.ts --outdir ./dist --target bun --packages external && tsc -p tsconfig.build.json",
|
|
42
47
|
"clean": "rm -rf dist",
|
|
43
48
|
"test": "bun test",
|
|
44
49
|
"typecheck": "tsc --noEmit"
|