New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

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

Package Overview
Dependencies
Maintainers
4
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 1.2.0 to 1.2.1

2

dist/declarations/src/index.d.ts

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

private readonly context;
private readonly options;
private readonly config;
private readonly onError;

@@ -16,0 +16,0 @@ constructor(context: ValidationContext, onError: (string: any) => any, options?: CostLimitOptions);

@@ -36,3 +36,3 @@ 'use strict';

_defineProperty(this, "options", void 0);
_defineProperty(this, "config", void 0);

@@ -42,3 +42,3 @@ _defineProperty(this, "onError", void 0);

this.context = context;
this.options = Object.assign({}, costLimitDefaultOptions, ...Object.entries(options ?? {}).map(([k, v]) => v === undefined ? {} : {
this.config = Object.assign({}, costLimitDefaultOptions, ...Object.entries(options ?? {}).map(([k, v]) => v === undefined ? {} : {
[k]: v

@@ -55,3 +55,3 @@ }));

if (complexity > this.options.maxCost) {
if (complexity > this.config.maxCost) {
this.onError(`Query is too expensive.`);

@@ -64,3 +64,3 @@ }

if (this.options.ignoreIntrospection && 'name' in node && ((_node$name = node.name) === null || _node$name === void 0 ? void 0 : _node$name.value) === '__schema') {
if (this.config.ignoreIntrospection && 'name' in node && ((_node$name = node.name) === null || _node$name === void 0 ? void 0 : _node$name.value) === '__schema') {
return 0;

@@ -72,9 +72,9 @@ } // const typeDefs: GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType = this.context

let cost = this.options.scalarCost;
let cost = this.config.scalarCost;
if ('selectionSet' in node && node.selectionSet) {
cost = this.options.objectCost;
cost = this.config.objectCost;
for (let child of node.selectionSet.selections) {
cost += this.options.depthCostFactor * this.computeComplexity(child, depth + 1);
cost += this.config.depthCostFactor * this.computeComplexity(child, depth + 1);
}

@@ -87,3 +87,3 @@ }

if (fragment) {
cost += this.options.depthCostFactor * this.computeComplexity(fragment, depth + 1);
cost += this.config.depthCostFactor * this.computeComplexity(fragment, depth + 1);
}

@@ -90,0 +90,0 @@ }

@@ -36,3 +36,3 @@ 'use strict';

_defineProperty(this, "options", void 0);
_defineProperty(this, "config", void 0);

@@ -42,3 +42,3 @@ _defineProperty(this, "onError", void 0);

this.context = context;
this.options = Object.assign({}, costLimitDefaultOptions, ...Object.entries(options ?? {}).map(([k, v]) => v === undefined ? {} : {
this.config = Object.assign({}, costLimitDefaultOptions, ...Object.entries(options ?? {}).map(([k, v]) => v === undefined ? {} : {
[k]: v

@@ -55,3 +55,3 @@ }));

if (complexity > this.options.maxCost) {
if (complexity > this.config.maxCost) {
this.onError(`Query is too expensive.`);

@@ -64,3 +64,3 @@ }

if (this.options.ignoreIntrospection && 'name' in node && ((_node$name = node.name) === null || _node$name === void 0 ? void 0 : _node$name.value) === '__schema') {
if (this.config.ignoreIntrospection && 'name' in node && ((_node$name = node.name) === null || _node$name === void 0 ? void 0 : _node$name.value) === '__schema') {
return 0;

@@ -72,9 +72,9 @@ } // const typeDefs: GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType = this.context

let cost = this.options.scalarCost;
let cost = this.config.scalarCost;
if ('selectionSet' in node && node.selectionSet) {
cost = this.options.objectCost;
cost = this.config.objectCost;
for (let child of node.selectionSet.selections) {
cost += this.options.depthCostFactor * this.computeComplexity(child, depth + 1);
cost += this.config.depthCostFactor * this.computeComplexity(child, depth + 1);
}

@@ -87,3 +87,3 @@ }

if (fragment) {
cost += this.options.depthCostFactor * this.computeComplexity(fragment, depth + 1);
cost += this.config.depthCostFactor * this.computeComplexity(fragment, depth + 1);
}

@@ -90,0 +90,0 @@ }

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

_defineProperty(this, "options", void 0);
_defineProperty(this, "config", void 0);

@@ -38,3 +38,3 @@ _defineProperty(this, "onError", void 0);

this.context = context;
this.options = Object.assign({}, costLimitDefaultOptions, ...Object.entries(options ?? {}).map(([k, v]) => v === undefined ? {} : {
this.config = Object.assign({}, costLimitDefaultOptions, ...Object.entries(options ?? {}).map(([k, v]) => v === undefined ? {} : {
[k]: v

@@ -51,3 +51,3 @@ }));

if (complexity > this.options.maxCost) {
if (complexity > this.config.maxCost) {
this.onError(`Query is too expensive.`);

@@ -60,3 +60,3 @@ }

if (this.options.ignoreIntrospection && 'name' in node && ((_node$name = node.name) === null || _node$name === void 0 ? void 0 : _node$name.value) === '__schema') {
if (this.config.ignoreIntrospection && 'name' in node && ((_node$name = node.name) === null || _node$name === void 0 ? void 0 : _node$name.value) === '__schema') {
return 0;

@@ -68,9 +68,9 @@ } // const typeDefs: GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType = this.context

let cost = this.options.scalarCost;
let cost = this.config.scalarCost;
if ('selectionSet' in node && node.selectionSet) {
cost = this.options.objectCost;
cost = this.config.objectCost;
for (let child of node.selectionSet.selections) {
cost += this.options.depthCostFactor * this.computeComplexity(child, depth + 1);
cost += this.config.depthCostFactor * this.computeComplexity(child, depth + 1);
}

@@ -83,3 +83,3 @@ }

if (fragment) {
cost += this.options.depthCostFactor * this.computeComplexity(fragment, depth + 1);
cost += this.config.depthCostFactor * this.computeComplexity(fragment, depth + 1);
}

@@ -86,0 +86,0 @@ }

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

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

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