@escape.tech/graphql-armor-cost-limit
Advanced tools
Comparing version 1.7.0 to 1.7.1
@@ -10,2 +10,3 @@ import type { Plugin } from '@envelop/core'; | ||
ignoreIntrospection?: boolean; | ||
fragmentRecursionCost?: number; | ||
} & GraphQLArmorCallbackConfiguration; | ||
@@ -16,2 +17,3 @@ declare class CostLimitVisitor { | ||
private readonly config; | ||
private readonly visitedFragments; | ||
constructor(context: ValidationContext, options?: CostLimitOptions); | ||
@@ -18,0 +20,0 @@ onOperationDefinitionEnter(operation: OperationDefinitionNode): void; |
@@ -27,2 +27,3 @@ 'use strict'; | ||
depthCostFactor: 1.5, | ||
fragmentRecursionCost: 1000, | ||
ignoreIntrospection: true, | ||
@@ -42,2 +43,4 @@ onAccept: [], | ||
_defineProperty(this, "visitedFragments", new Set()); | ||
this.context = context; | ||
@@ -99,2 +102,7 @@ this.config = Object.assign({}, costLimitDefaultOptions, ...Object.entries(options !== null && options !== void 0 ? options : {}).map(([k, v]) => v === undefined ? {} : { | ||
if (node.kind == graphql.Kind.FRAGMENT_SPREAD) { | ||
if (this.visitedFragments.has(node.name.value)) { | ||
return this.config.fragmentRecursionCost; | ||
} | ||
this.visitedFragments.add(node.name.value); | ||
const fragment = this.context.getFragment(node.name.value); | ||
@@ -101,0 +109,0 @@ |
@@ -27,2 +27,3 @@ 'use strict'; | ||
depthCostFactor: 1.5, | ||
fragmentRecursionCost: 1000, | ||
ignoreIntrospection: true, | ||
@@ -42,2 +43,4 @@ onAccept: [], | ||
_defineProperty(this, "visitedFragments", new Set()); | ||
this.context = context; | ||
@@ -99,2 +102,7 @@ this.config = Object.assign({}, costLimitDefaultOptions, ...Object.entries(options !== null && options !== void 0 ? options : {}).map(([k, v]) => v === undefined ? {} : { | ||
if (node.kind == graphql.Kind.FRAGMENT_SPREAD) { | ||
if (this.visitedFragments.has(node.name.value)) { | ||
return this.config.fragmentRecursionCost; | ||
} | ||
this.visitedFragments.add(node.name.value); | ||
const fragment = this.context.getFragment(node.name.value); | ||
@@ -101,0 +109,0 @@ |
@@ -23,2 +23,3 @@ import { GraphQLError, Kind } from 'graphql'; | ||
depthCostFactor: 1.5, | ||
fragmentRecursionCost: 1000, | ||
ignoreIntrospection: true, | ||
@@ -38,2 +39,4 @@ onAccept: [], | ||
_defineProperty(this, "visitedFragments", new Set()); | ||
this.context = context; | ||
@@ -95,2 +98,7 @@ this.config = Object.assign({}, costLimitDefaultOptions, ...Object.entries(options !== null && options !== void 0 ? options : {}).map(([k, v]) => v === undefined ? {} : { | ||
if (node.kind == Kind.FRAGMENT_SPREAD) { | ||
if (this.visitedFragments.has(node.name.value)) { | ||
return this.config.fragmentRecursionCost; | ||
} | ||
this.visitedFragments.add(node.name.value); | ||
const fragment = this.context.getFragment(node.name.value); | ||
@@ -97,0 +105,0 @@ |
{ | ||
"name": "@escape.tech/graphql-armor-cost-limit", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"description": "Limit the cost of a GraphQL Query.", | ||
@@ -39,4 +39,4 @@ "packageManager": "yarn@3.3.1", | ||
"graphql": "16.6.0", | ||
"typescript": "4.9.4" | ||
"typescript": "4.9.5" | ||
} | ||
} |
13455
330