From a393385473b3073c1481aaa4d1a866d1abbcefdd Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Wed, 1 Nov 2023 13:03:18 +0100 Subject: [PATCH] Early return when complexity is disabled This allows other validation rules to depend on the `QueryComplexity` rule, and disable the query complexity completely on some condition. --- src/Validator/Rules/QueryComplexity.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Validator/Rules/QueryComplexity.php b/src/Validator/Rules/QueryComplexity.php index 812482f8f..e123b1de9 100644 --- a/src/Validator/Rules/QueryComplexity.php +++ b/src/Validator/Rules/QueryComplexity.php @@ -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) {