Skip to content

Commit

Permalink
Early return when complexity is disabled
Browse files Browse the repository at this point in the history
This allows other validation rules to depend on the `QueryComplexity` rule, and disable
the query complexity completely on some condition.
  • Loading branch information
ruudk authored and spawnia committed Nov 14, 2023
1 parent b3b1e69 commit a393385
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Validator/Rules/QueryComplexity.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public function getVisitor(QueryValidationContext $context): array
return;
}

if ($this->maxQueryComplexity === self::DISABLED) {
return;
}

$complexity = $this->fieldComplexity($operationDefinition->selectionSet);

if ($complexity <= $this->maxQueryComplexity) {
Expand Down

0 comments on commit a393385

Please sign in to comment.