Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@escape.tech/graphql-armor-cost-limit

Package Overview
Dependencies
Maintainers
6
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@escape.tech/graphql-armor-cost-limit - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

1

dist/declarations/src/index.d.ts

@@ -9,2 +9,3 @@ import type { Plugin } from '@envelop/core';

depthCostFactor?: number;
flattenFragments?: boolean;
ignoreIntrospection?: boolean;

@@ -11,0 +12,0 @@ fragmentRecursionCost?: number;

2

dist/graphql-armor-cost-limit.cjs.d.ts

@@ -1,2 +0,2 @@

export * from "./declarations/src/index";
export * from "./declarations/src/index.js";
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3JhcGhxbC1hcm1vci1jb3N0LWxpbWl0LmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi9kZWNsYXJhdGlvbnMvc3JjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==

@@ -43,2 +43,3 @@ 'use strict';

depthCostFactor: 1.5,
flattenFragments: false,
fragmentRecursionCost: 1000,

@@ -97,6 +98,9 @@ ignoreIntrospection: true,

for (const child of node.selectionSet.selections) {
cost += this.config.depthCostFactor * this.computeComplexity(child, depth + 1);
if (this.config.flattenFragments && (child.kind === graphql.Kind.INLINE_FRAGMENT || child.kind === graphql.Kind.FRAGMENT_SPREAD)) {
cost += this.computeComplexity(child, depth);
} else {
cost += this.config.depthCostFactor * this.computeComplexity(child, depth + 1);
}
}
}
if (node.kind === graphql.Kind.FRAGMENT_SPREAD) {
} else if (node.kind === graphql.Kind.FRAGMENT_SPREAD) {
if (this.visitedFragments.has(node.name.value)) {

@@ -111,7 +115,13 @@ var _this$visitedFragment;

if (fragment) {
const additionalCost = this.computeComplexity(fragment, depth + 1);
let fragmentCost;
if (this.config.flattenFragments) {
fragmentCost = this.computeComplexity(fragment, depth);
cost += fragmentCost;
} else {
fragmentCost = this.computeComplexity(fragment, depth + 1);
cost += this.config.depthCostFactor * fragmentCost;
}
if (this.visitedFragments.get(node.name.value) === -1) {
this.visitedFragments.set(node.name.value, additionalCost);
this.visitedFragments.set(node.name.value, fragmentCost);
}
cost += this.config.depthCostFactor * additionalCost;
}

@@ -118,0 +128,0 @@ }

@@ -43,2 +43,3 @@ 'use strict';

depthCostFactor: 1.5,
flattenFragments: false,
fragmentRecursionCost: 1000,

@@ -97,6 +98,9 @@ ignoreIntrospection: true,

for (const child of node.selectionSet.selections) {
cost += this.config.depthCostFactor * this.computeComplexity(child, depth + 1);
if (this.config.flattenFragments && (child.kind === graphql.Kind.INLINE_FRAGMENT || child.kind === graphql.Kind.FRAGMENT_SPREAD)) {
cost += this.computeComplexity(child, depth);
} else {
cost += this.config.depthCostFactor * this.computeComplexity(child, depth + 1);
}
}
}
if (node.kind === graphql.Kind.FRAGMENT_SPREAD) {
} else if (node.kind === graphql.Kind.FRAGMENT_SPREAD) {
if (this.visitedFragments.has(node.name.value)) {

@@ -111,7 +115,13 @@ var _this$visitedFragment;

if (fragment) {
const additionalCost = this.computeComplexity(fragment, depth + 1);
let fragmentCost;
if (this.config.flattenFragments) {
fragmentCost = this.computeComplexity(fragment, depth);
cost += fragmentCost;
} else {
fragmentCost = this.computeComplexity(fragment, depth + 1);
cost += this.config.depthCostFactor * fragmentCost;
}
if (this.visitedFragments.get(node.name.value) === -1) {
this.visitedFragments.set(node.name.value, additionalCost);
this.visitedFragments.set(node.name.value, fragmentCost);
}
cost += this.config.depthCostFactor * additionalCost;
}

@@ -118,0 +128,0 @@ }

@@ -39,2 +39,3 @@ import { GraphQLError, Kind } from 'graphql';

depthCostFactor: 1.5,
flattenFragments: false,
fragmentRecursionCost: 1000,

@@ -93,6 +94,9 @@ ignoreIntrospection: true,

for (const child of node.selectionSet.selections) {
cost += this.config.depthCostFactor * this.computeComplexity(child, depth + 1);
if (this.config.flattenFragments && (child.kind === Kind.INLINE_FRAGMENT || child.kind === Kind.FRAGMENT_SPREAD)) {
cost += this.computeComplexity(child, depth);
} else {
cost += this.config.depthCostFactor * this.computeComplexity(child, depth + 1);
}
}
}
if (node.kind === Kind.FRAGMENT_SPREAD) {
} else if (node.kind === Kind.FRAGMENT_SPREAD) {
if (this.visitedFragments.has(node.name.value)) {

@@ -107,7 +111,13 @@ var _this$visitedFragment;

if (fragment) {
const additionalCost = this.computeComplexity(fragment, depth + 1);
let fragmentCost;
if (this.config.flattenFragments) {
fragmentCost = this.computeComplexity(fragment, depth);
cost += fragmentCost;
} else {
fragmentCost = this.computeComplexity(fragment, depth + 1);
cost += this.config.depthCostFactor * fragmentCost;
}
if (this.visitedFragments.get(node.name.value) === -1) {
this.visitedFragments.set(node.name.value, additionalCost);
this.visitedFragments.set(node.name.value, fragmentCost);
}
cost += this.config.depthCostFactor * additionalCost;
}

@@ -114,0 +124,0 @@ }

{
"name": "@escape.tech/graphql-armor-cost-limit",
"version": "2.3.0",
"version": "2.4.0",
"description": "Limit the cost of a GraphQL Query.",

@@ -5,0 +5,0 @@ "packageManager": "yarn@4.5.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc