QueryComplexity throws a raw Error out of DocumentValidator::validate() instead of reporting it through the validation context. Every other rule reports errors, and validate() is documented to return them, so callers using DocumentValidator directly (rather than GraphQL::promiseToExecute(), which sets the variables and wraps everything in try/catch) get an uncaught exception.
Repro (v15.37.2):
$rules = [new QueryComplexity(100)];
DocumentValidator::validate(
$schema,
Parser::parse('query ($withDetails: Boolean!) { field { details @include(if: $withDetails) { name } } }'),
$rules,
); // throws GraphQL\Error\Error: Variable "$withDetails" of required type "Boolean!" was not provided.
Source: QueryComplexity::getCoercedVariableValues() throws on coercion errors; it is reached from directiveExcludesField() and buildFieldArguments().
Expected: the coercion errors are reported via $context->reportError() (or the rule is a no-op) so validate() returns them like any other validation error.
Reported on behalf of @ruudk.
QueryComplexitythrows a rawErrorout ofDocumentValidator::validate()instead of reporting it through the validation context. Every other rule reports errors, andvalidate()is documented to return them, so callers usingDocumentValidatordirectly (rather thanGraphQL::promiseToExecute(), which sets the variables and wraps everything intry/catch) get an uncaught exception.Repro (v15.37.2):
Source:
QueryComplexity::getCoercedVariableValues()throws on coercion errors; it is reached fromdirectiveExcludesField()andbuildFieldArguments().Expected: the coercion errors are reported via
$context->reportError()(or the rule is a no-op) sovalidate()returns them like any other validation error.Reported on behalf of @ruudk.