This repository was archived by the owner on Apr 29, 2019. It is now read-only.
File tree 2 files changed +9
-7
lines changed
lib/internal/Magento/Framework/GraphQl/Query
2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 16
16
* Sets limits for query complexity. A single GraphQL query can potentially
17
17
* generate thousands of database operations so, the very complex queries
18
18
* should be filtered and rejected.
19
+ *
20
+ * https://github.com/webonyx/graphql-php/blob/master/docs/security.md#query-complexity-analysis
19
21
*/
20
22
class QueryComplexityLimiter
21
23
{
@@ -42,15 +44,15 @@ public function __construct(
42
44
}
43
45
44
46
/**
45
- * @param bool $disableIntrospection
47
+ * @param bool $developerMode
46
48
*/
47
- public function execute (bool $ disableIntrospection = false ): void
49
+ public function execute (bool $ developerMode = false ): void
48
50
{
49
- DocumentValidator::addRule (new QueryDepth ($ this ->queryDepth ));
50
51
DocumentValidator::addRule (new QueryComplexity ($ this ->queryComplexity ));
51
52
52
- if ($ disableIntrospection ) {
53
+ if (! $ developerMode ) {
53
54
DocumentValidator::addRule (new DisableIntrospection ());
55
+ DocumentValidator::addRule (new QueryDepth ($ this ->queryDepth ));
54
56
}
55
57
}
56
58
}
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ class QueryProcessor
24
24
/**
25
25
* @var QueryComplexityLimiter
26
26
*/
27
- protected $ queryComplexityLimiter ;
27
+ private $ queryComplexityLimiter ;
28
28
29
29
/**
30
30
* @param ExceptionFormatter $exceptionFormatter
@@ -55,8 +55,8 @@ public function process(
55
55
array $ variableValues = null ,
56
56
string $ operationName = null
57
57
) : array {
58
- $ disableIntrospection = !$ this ->exceptionFormatter ->shouldShowDetail ();
59
- $ this ->queryComplexityLimiter ->execute ($ disableIntrospection );
58
+ $ developerMode = !$ this ->exceptionFormatter ->shouldShowDetail ();
59
+ $ this ->queryComplexityLimiter ->execute ($ developerMode );
60
60
61
61
$ rootValue = null ;
62
62
return \GraphQL \GraphQL::executeQuery (
You can’t perform that action at this time.
0 commit comments