graphql-query-complexity
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -12,3 +12,5 @@ "use strict"; | ||
type: Item, | ||
complexity: (args) => args.childComplexity * (args.args.count || 10), | ||
extensions: { | ||
complexity: (args) => args.childComplexity * (args.args.count || 10) | ||
}, | ||
args: { | ||
@@ -21,6 +23,8 @@ count: { | ||
scalar: { type: graphql_1.GraphQLString }, | ||
complexScalar: { type: graphql_1.GraphQLString, complexity: 20 }, | ||
complexScalar: { type: graphql_1.GraphQLString, extensions: { complexity: 20 } }, | ||
variableScalar: { | ||
type: Item, | ||
complexity: (args) => 10 * (args.args.count || 10), | ||
extensions: { | ||
complexity: (args) => 10 * (args.args.count || 10) | ||
}, | ||
args: { | ||
@@ -84,3 +88,5 @@ count: { | ||
type: Item, | ||
complexity: (args) => args.childComplexity * (args.args.count || 10), | ||
extensions: { | ||
complexity: (args) => args.childComplexity * (args.args.count || 10) | ||
}, | ||
args: { | ||
@@ -95,7 +101,9 @@ count: { | ||
scalar: { type: graphql_1.GraphQLString }, | ||
complexScalar: { type: graphql_1.GraphQLString, complexity: 20 }, | ||
complexScalar: { type: graphql_1.GraphQLString, extensions: { complexity: 20 } }, | ||
union: { type: Union }, | ||
variableScalar: { | ||
type: Item, | ||
complexity: (args) => 10 * (args.args.count || 10), | ||
extensions: { | ||
complexity: (args) => 10 * (args.args.count || 10) | ||
}, | ||
args: { | ||
@@ -102,0 +110,0 @@ count: { |
@@ -21,2 +21,3 @@ "use strict"; | ||
const index_1 = require("../index"); | ||
const CompatibleValidationContext_1 = require("./fixtures/CompatibleValidationContext"); | ||
describe('QueryComplexity analysis', () => { | ||
@@ -122,3 +123,3 @@ const typeInfo = new graphql_1.TypeInfo(schema_1.default); | ||
estimators: [ | ||
index_1.fieldConfigEstimator(), | ||
index_1.fieldExtensionsEstimator(), | ||
index_1.simpleEstimator({ defaultComplexity: 1 }) | ||
@@ -140,3 +141,3 @@ ], | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -157,7 +158,7 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
maximumComplexity: 100, | ||
estimators: [ | ||
index_1.fieldConfigEstimator(), | ||
index_1.fieldExtensionsEstimator(), | ||
index_1.simpleEstimator({ | ||
@@ -183,7 +184,7 @@ defaultComplexity: 1 | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
maximumComplexity: 100, | ||
estimators: [ | ||
index_1.fieldConfigEstimator(), | ||
index_1.fieldExtensionsEstimator(), | ||
index_1.simpleEstimator({ | ||
@@ -208,7 +209,7 @@ defaultComplexity: 1 | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
maximumComplexity: 100, | ||
estimators: [ | ||
index_1.fieldConfigEstimator(), | ||
index_1.fieldExtensionsEstimator(), | ||
index_1.simpleEstimator({ | ||
@@ -233,7 +234,7 @@ defaultComplexity: 1 | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
maximumComplexity: 100, | ||
estimators: [ | ||
index_1.fieldConfigEstimator(), | ||
index_1.fieldExtensionsEstimator(), | ||
index_1.simpleEstimator({ | ||
@@ -258,7 +259,7 @@ defaultComplexity: 1 | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
maximumComplexity: 100, | ||
estimators: [ | ||
index_1.fieldConfigEstimator(), | ||
index_1.fieldExtensionsEstimator(), | ||
index_1.simpleEstimator({ | ||
@@ -282,7 +283,7 @@ defaultComplexity: 1 | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
maximumComplexity: 100, | ||
estimators: [ | ||
index_1.fieldConfigEstimator(), | ||
index_1.fieldExtensionsEstimator(), | ||
index_1.simpleEstimator({ | ||
@@ -302,7 +303,7 @@ defaultComplexity: 1 | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
maximumComplexity: 100, | ||
estimators: [ | ||
index_1.fieldConfigEstimator(), | ||
index_1.fieldExtensionsEstimator(), | ||
index_1.simpleEstimator({ | ||
@@ -322,7 +323,7 @@ defaultComplexity: 1 | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
maximumComplexity: 100, | ||
estimators: [ | ||
index_1.fieldConfigEstimator(), | ||
index_1.fieldExtensionsEstimator(), | ||
index_1.simpleEstimator({ | ||
@@ -343,3 +344,3 @@ defaultComplexity: 1 | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -360,7 +361,7 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
maximumComplexity: 100, | ||
estimators: [ | ||
index_1.fieldConfigEstimator() | ||
index_1.fieldExtensionsEstimator() | ||
] | ||
@@ -423,3 +424,3 @@ }); | ||
estimators: [ | ||
index_1.fieldConfigEstimator(), | ||
index_1.fieldExtensionsEstimator(), | ||
index_1.simpleEstimator({ defaultComplexity: 1 }) | ||
@@ -433,3 +434,3 @@ ], | ||
estimators: [ | ||
index_1.fieldConfigEstimator(), | ||
index_1.fieldExtensionsEstimator(), | ||
index_1.simpleEstimator({ defaultComplexity: 1 }) | ||
@@ -436,0 +437,0 @@ ], |
@@ -14,2 +14,3 @@ "use strict"; | ||
const index_1 = __importDefault(require("../index")); | ||
const CompatibleValidationContext_1 = require("../../../__tests__/fixtures/CompatibleValidationContext"); | ||
describe('directiveEstimator analysis', () => { | ||
@@ -23,3 +24,3 @@ const typeInfo = new graphql_1.TypeInfo(schema_1.default); | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -40,3 +41,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -57,3 +58,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -74,3 +75,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -95,3 +96,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -114,3 +115,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -133,3 +134,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -152,3 +153,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -171,3 +172,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -190,3 +191,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -207,3 +208,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -216,6 +217,6 @@ maximumComplexity: 100, | ||
graphql_1.visit(ast, graphql_1.visitWithTypeInfo(typeInfo, visitor)); | ||
chai_1.expect(visitor.context.getErrors().length).to.equal(1); | ||
chai_1.expect(visitor.context.getErrors()[0].message).to.include('No complexity could be calculated for field Query.noDirective'); | ||
chai_1.expect(context.getErrors().length).to.equal(1); | ||
chai_1.expect(context.getErrors()[0].message).to.include('No complexity could be calculated for field Query.noDirective'); | ||
}); | ||
}); | ||
//# sourceMappingURL=directiveEstimator-test.js.map |
@@ -15,2 +15,3 @@ "use strict"; | ||
const index_1 = __importDefault(require("../index")); | ||
const CompatibleValidationContext_1 = require("../../../__tests__/fixtures/CompatibleValidationContext"); | ||
describe('fieldExtensions estimator', () => { | ||
@@ -24,3 +25,3 @@ const typeInfo = new graphql_1.TypeInfo(schema_1.default); | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -44,3 +45,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -64,3 +65,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -84,3 +85,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -104,3 +105,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -130,3 +131,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -155,3 +156,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -180,3 +181,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -205,3 +206,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -229,3 +230,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -249,3 +250,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -269,3 +270,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -272,0 +273,0 @@ maximumComplexity: 100, |
export { default as simpleEstimator } from './simple'; | ||
export { default as legacyEstimator } from './legacy'; | ||
export { default as fieldConfigEstimator } from './fieldConfig'; | ||
export { default as directiveEstimator } from './directive'; | ||
export { default as fieldExtensionsEstimator } from './fieldExtensions'; |
@@ -5,6 +5,2 @@ "use strict"; | ||
exports.simpleEstimator = simple_1.default; | ||
var legacy_1 = require("./legacy"); | ||
exports.legacyEstimator = legacy_1.default; | ||
var fieldConfig_1 = require("./fieldConfig"); | ||
exports.fieldConfigEstimator = fieldConfig_1.default; | ||
var directive_1 = require("./directive"); | ||
@@ -11,0 +7,0 @@ exports.directiveEstimator = directive_1.default; |
@@ -14,2 +14,3 @@ "use strict"; | ||
const QueryComplexity_1 = __importDefault(require("../../../QueryComplexity")); | ||
const CompatibleValidationContext_1 = require("../../../__tests__/fixtures/CompatibleValidationContext"); | ||
describe('simple estimator', () => { | ||
@@ -23,3 +24,3 @@ const typeInfo = new graphql_1.TypeInfo(schema_1.default); | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -40,3 +41,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -57,3 +58,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -74,3 +75,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -97,3 +98,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -119,3 +120,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -140,3 +141,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -162,3 +163,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -183,3 +184,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -200,3 +201,3 @@ maximumComplexity: 100, | ||
`); | ||
const context = new graphql_1.ValidationContext(schema_1.default, ast, typeInfo); | ||
const context = new CompatibleValidationContext_1.CompatibleValidationContext(schema_1.default, ast, typeInfo); | ||
const visitor = new QueryComplexity_1.default(context, { | ||
@@ -203,0 +204,0 @@ maximumComplexity: 100, |
@@ -0,4 +1,11 @@ | ||
/** | ||
* Created by Ivo Meißner on 28.07.17. | ||
* | ||
* @flow | ||
*/ | ||
import { ValidationContext } from 'graphql'; | ||
import QueryComplexity from './QueryComplexity'; | ||
import { QueryComplexityOptions } from './QueryComplexity'; | ||
export * from './estimators'; | ||
export * from './QueryComplexity'; | ||
export default function createQueryComplexityValidator(options: QueryComplexityOptions): Function; | ||
export default function createQueryComplexityValidator(options: QueryComplexityOptions): (context: ValidationContext) => QueryComplexity; |
@@ -29,3 +29,3 @@ /** | ||
createError?: (max: number, actual: number) => GraphQLError; | ||
estimators?: Array<ComplexityEstimator>; | ||
estimators: Array<ComplexityEstimator>; | ||
} | ||
@@ -32,0 +32,0 @@ export declare function getComplexity(options: { |
@@ -9,3 +9,2 @@ "use strict"; | ||
const graphql_2 = require("graphql"); | ||
const estimators_1 = require("./estimators"); | ||
function queryComplexityMessage(max, actual) { | ||
@@ -17,3 +16,3 @@ return (`The query exceeds the maximum complexity of ${max}. ` + | ||
const typeInfo = new graphql_1.TypeInfo(options.schema); | ||
const context = new graphql_1.ValidationContext(options.schema, options.query, typeInfo); | ||
const context = new graphql_1.ValidationContext(options.schema, options.query, typeInfo, () => null); | ||
const visitor = new QueryComplexity(context, { | ||
@@ -40,9 +39,3 @@ // Maximum complexity does not matter since we're only interested in the calculated complexity. | ||
this.skipDirectiveDef = this.context.getSchema().getDirective('skip'); | ||
if (!options.estimators) { | ||
console.warn('DEPRECATION WARNING: Estimators should be configured in the queryComplexity options.'); | ||
} | ||
this.estimators = options.estimators || [ | ||
estimators_1.legacyEstimator(), | ||
estimators_1.simpleEstimator() | ||
]; | ||
this.estimators = options.estimators; | ||
this.OperationDefinition = { | ||
@@ -49,0 +42,0 @@ enter: this.onOperationDefinitionEnter, |
{ | ||
"name": "graphql-query-complexity", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Validation rule for GraphQL query complexity analysis", | ||
@@ -12,3 +12,3 @@ "main": "dist/index.js", | ||
"test": "npm run lint && npm run testonly", | ||
"testonly": "mocha --check-leaks --exit --full-trace --require ts-node/register 'src/**/__tests__/**/*-test.{ts,tsx}'", | ||
"testonly": "mocha --check-leaks --exit --full-trace --require ts-node/register/transpile-only 'src/**/__tests__/**/*-test.{ts,tsx}'", | ||
"dist": "npm run clean && tsc && npm run build", | ||
@@ -24,3 +24,3 @@ "prepublish": "npm run clean && npm run dist" | ||
"peerDependencies": { | ||
"graphql": "^0.13.0 || ^14.0.0" | ||
"graphql": "^0.13.0 || ^14.0.0 || ^15.0.0" | ||
}, | ||
@@ -46,3 +46,2 @@ "files": [ | ||
"@types/chai": "^4.2.11", | ||
"@types/graphql": "^0.13.0 || ^14.0.0", | ||
"@types/lodash.get": "^4.4.6", | ||
@@ -54,3 +53,3 @@ "@types/mocha": "^7.0.2", | ||
"eslint": "^6.8.0", | ||
"graphql": "^0.13.0 || ^14.0.0", | ||
"graphql": "^14.5.0 || ^15.0.0", | ||
"mocha": "^7.1.1", | ||
@@ -57,0 +56,0 @@ "rimraf": "^3.0.2", |
@@ -86,6 +86,2 @@ # GraphQL Query Complexity Analysis for graphql-js | ||
function in the field config extensions of your schema. | ||
* **[`fieldConfigEstimator`](src/estimators/fieldConfig/README.md):** (DEPRECATED) The field config estimator lets you set a numeric value or a custom estimator | ||
function in the field config of your schema. | ||
* **[`legacyEstimator`](src/estimators/legacy/README.md):** (DEPRECATED) The legacy estimator implements the logic of previous versions. Can be used | ||
to gradually migrate your codebase to new estimators. | ||
* PRs welcome... | ||
@@ -92,0 +88,0 @@ |
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
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
Sorry, the diff of this file is not supported yet
13
126558
48
1948
178