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

Commit b1227fc

Browse files
committed
Changed query depth limiter behavior
1 parent ce50f48 commit b1227fc

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

app/code/Magento/GraphQl/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
</type>
100100
<type name="Magento\Framework\GraphQl\Query\QueryComplexityLimiter">
101101
<arguments>
102-
<argument name="queryDepth" xsi:type="number">10</argument>
102+
<argument name="queryDepth" xsi:type="number">15</argument>
103103
<argument name="queryComplexity" xsi:type="number">50</argument>
104104
</arguments>
105105
</type>

dev/tests/api-functional/testsuite/Magento/GraphQl/Framework/QueryComplexityLimiterTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
use Magento\TestFramework\TestCase\GraphQlAbstract;
1111

12+
/**
13+
* Tests query complexity limiter and depth limiter.
14+
* Actual for production mode only
15+
*/
1216
class QueryComplexityLimiterTest extends GraphQlAbstract
1317
{
1418
/**
@@ -159,7 +163,7 @@ public function testQueryDepthIsLimited()
159163
}
160164
}
161165
QUERY;
162-
self::expectExceptionMessageRegExp('/Max query depth should be 10 but got 20/');
166+
self::expectExceptionMessageRegExp('/Max query depth should be 15 but got 20/');
163167
$this->graphQlQuery($query);
164168
}
165169
}

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,17 @@ class QueryComplexityLimiter
3636
* @param int $queryComplexity
3737
*/
3838
public function __construct(
39-
int $queryDepth = 10,
39+
int $queryDepth = 15,
4040
int $queryComplexity = 50
4141
) {
4242
$this->queryDepth = $queryDepth;
4343
$this->queryComplexity = $queryComplexity;
4444
}
4545

46-
/**
47-
* @param bool $developerMode
48-
*/
49-
public function execute(bool $developerMode = false): void
46+
public function execute(): void
5047
{
5148
DocumentValidator::addRule(new QueryComplexity($this->queryComplexity));
52-
53-
if (!$developerMode) {
54-
DocumentValidator::addRule(new DisableIntrospection());
55-
DocumentValidator::addRule(new QueryDepth($this->queryDepth));
56-
}
49+
DocumentValidator::addRule(new DisableIntrospection());
50+
DocumentValidator::addRule(new QueryDepth($this->queryDepth));
5751
}
5852
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ public function process(
5555
array $variableValues = null,
5656
string $operationName = null
5757
) : array {
58-
$developerMode = !$this->exceptionFormatter->shouldShowDetail();
59-
$this->queryComplexityLimiter->execute($developerMode);
58+
var_dump($this->exceptionFormatter->shouldShowDetail());
59+
if (!$this->exceptionFormatter->shouldShowDetail()) {
60+
$this->queryComplexityLimiter->execute();
61+
}
6062

6163
$rootValue = null;
6264
return \GraphQL\GraphQL::executeQuery(

0 commit comments

Comments
 (0)