Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 335c173

Browse files
committed
Adjusted complexity limiter for developer mode
1 parent 99b1d1d commit 335c173

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lib/internal/Magento/Framework/GraphQl/Query/QueryComplexityLimiter.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* Sets limits for query complexity. A single GraphQL query can potentially
1717
* generate thousands of database operations so, the very complex queries
1818
* should be filtered and rejected.
19+
*
20+
* https://github.com/webonyx/graphql-php/blob/master/docs/security.md#query-complexity-analysis
1921
*/
2022
class QueryComplexityLimiter
2123
{
@@ -42,15 +44,15 @@ public function __construct(
4244
}
4345

4446
/**
45-
* @param bool $disableIntrospection
47+
* @param bool $developerMode
4648
*/
47-
public function execute(bool $disableIntrospection = false): void
49+
public function execute(bool $developerMode = false): void
4850
{
49-
DocumentValidator::addRule(new QueryDepth($this->queryDepth));
5051
DocumentValidator::addRule(new QueryComplexity($this->queryComplexity));
5152

52-
if ($disableIntrospection) {
53+
if (!$developerMode) {
5354
DocumentValidator::addRule(new DisableIntrospection());
55+
DocumentValidator::addRule(new QueryDepth($this->queryDepth));
5456
}
5557
}
5658
}

lib/internal/Magento/Framework/GraphQl/Query/QueryProcessor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class QueryProcessor
2424
/**
2525
* @var QueryComplexityLimiter
2626
*/
27-
protected $queryComplexityLimiter;
27+
private $queryComplexityLimiter;
2828

2929
/**
3030
* @param ExceptionFormatter $exceptionFormatter
@@ -55,8 +55,8 @@ public function process(
5555
array $variableValues = null,
5656
string $operationName = null
5757
) : array {
58-
$disableIntrospection = !$this->exceptionFormatter->shouldShowDetail();
59-
$this->queryComplexityLimiter->execute($disableIntrospection);
58+
$developerMode = !$this->exceptionFormatter->shouldShowDetail();
59+
$this->queryComplexityLimiter->execute($developerMode);
6060

6161
$rootValue = null;
6262
return \GraphQL\GraphQL::executeQuery(

0 commit comments

Comments
 (0)