Description
Schema / Definition:
directive @complexity(
# The complexity value for the field
value: Int!,
# Optional multipliers
multipliers: [String!]
) on FIELD_DEFINITION
myProperties ( limit: Int!, findOptions: JSON ):
PropertiesConnection @auth @complexity(value: 5, multipliers:["limit"])
...
Added to validationRules: (ApolloServer 2
)
validationRules: [ queryComplexity.default({
estimators: [
directiveEstimator({
name: 'complexity',
}),
],
maximumComplexity: 1000,
variables: req.body.variables || {},
// Optional function to create a custom error
createError: (max, actual) => {
return new GraphQLError(`Query is too complex: ${actual}. Maximum allowed complexity: ${max}`);
},
onComplete: (complexity) => {console.log('Query Complexity:', complexity);},
})]
the Query:
myProperties (
limit: 5
) {
nodes {
title
}
}
and above code throws the following error:
{
"statusCode": 500,
"error": "Internal Server Error",
"message": "Cannot read property 'multipliers' of undefined"
}
any clue, what am doing wrong? BTW simpleEstimator
works fine.
Metadata
Metadata
Assignees
Labels
No labels