You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP

graphql-query-complexity

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-query-complexity - npm Package Compare versions

Comparing version

to
0.4.1

@@ -69,2 +69,9 @@ "use strict";

});
const SDLInterface = new graphql_1.GraphQLInterfaceType({
name: 'SDLInterface',
fields: {
sdl: { type: graphql_1.GraphQLString }
},
resolveType: () => '"SDL"'
});
const Query = new graphql_1.GraphQLObjectType({

@@ -113,3 +120,4 @@ name: 'Query',

}
}
},
_service: { type: SDLInterface },
}),

@@ -116,0 +124,0 @@ });

@@ -285,3 +285,40 @@ "use strict";

});
it('should return NaN when no astNode available on field when use directiveEstimator', () => {
const ast = graphql_1.parse(`
query {
_service {
sdl
}
}
`);
const complexity = QueryComplexity_1.getComplexity({
estimators: [
index_1.directiveEstimator(),
],
schema: schema_1.default,
query: ast
});
chai_1.expect(Number.isNaN(complexity)).to.equal(true);
});
it('should skip complexity calculation by directiveEstimator when no astNode available on field', () => {
const ast = graphql_1.parse(`
query {
_service {
sdl
}
}
`);
const complexity = QueryComplexity_1.getComplexity({
estimators: [
index_1.directiveEstimator(),
index_1.simpleEstimator({
defaultComplexity: 1
})
],
schema: schema_1.default,
query: ast
});
chai_1.expect(complexity).to.equal(2);
});
});
//# sourceMappingURL=QueryComplexity-test.js.map

@@ -29,2 +29,6 @@ "use strict";

return (args) => {
// Ignore if astNode is undefined
if (!args.field.astNode) {
return;
}
const values = graphql_1.getDirectiveValues(directive, args.field.astNode);

@@ -31,0 +35,0 @@ // Ignore if no directive set

{
"name": "graphql-query-complexity",
"version": "0.4.0",
"version": "0.4.1",
"description": "Validation rule for GraphQL query complexity analysis",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

# GraphQL Query Complexity Analysis for graphql-js
[![npm version](https://badge.fury.io/js/graphql-query-complexity.svg)](https://badge.fury.io/js/graphql-query-complexity)
[![CircleCI](https://circleci.com/gh/slicknode/graphql-query-complexity.svg?style=shield)](https://circleci.com/gh/slicknode/graphql-query-complexity)
This library provides GraphQL query analysis to reject complex queries to your GraphQL server.

@@ -4,0 +8,0 @@ This can be used to protect your GraphQL servers against resource exhaustion and DoS attacks.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet