Skip to content

QueryComplexity throws instead of reporting validation errors #1967

Description

@devin-ai-integration

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions