b374k
m1n1 1.01
Apache/2.4.41 (Ubuntu)
Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64
uid=33(www-data) gid=33(www-data) groups=33(www-data)
server ip : 62.171.164.128 | your ip : 127.0.0.1
safemode OFF
 >  / home / dev2.destoffenstraat.com / vendor / magento / framework / GraphQl / Query /
Filename/home/dev2.destoffenstraat.com/vendor/magento/framework/GraphQl/Query/QueryComplexityLimiter.php
Size1.76 kb
Permissionrw-r--r--
Ownerroot : root
Create time17-Aug-2025 10:26
Last modified07-Jan-2021 21:08
Last accessed23-Aug-2025 03:56
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Framework\GraphQl\Query;

use GraphQL\Validator\DocumentValidator;
use GraphQL\Validator\Rules\DisableIntrospection;
use GraphQL\Validator\Rules\QueryDepth;
use GraphQL\Validator\Rules\QueryComplexity;

/**
* QueryComplexityLimiter
*
* Sets limits for query complexity. A single GraphQL query can potentially
* generate thousands of database operations so, the very complex queries
* should be filtered and rejected.
*
* https://github.com/webonyx/graphql-php/blob/master/docs/security.md#query-complexity-analysis
*/
class QueryComplexityLimiter
{
/**
* @var int
*/
private $queryDepth;

/**
* @var int
*/
private $queryComplexity;

/**
* @var IntrospectionConfiguration
*/
private $introspectionConfig;

/**
* @param int $queryDepth
* @param int $queryComplexity
* @param IntrospectionConfiguration $introspectionConfig
*/
public function __construct(
int $queryDepth,
int $queryComplexity,
IntrospectionConfiguration $introspectionConfig
) {
$this->queryDepth = $queryDepth;
$this->queryComplexity = $queryComplexity;
$this->introspectionConfig = $introspectionConfig;
}

/**
* Sets limits for query complexity
*
* @return void
*/
public function execute(): void
{
DocumentValidator::addRule(new QueryComplexity($this->queryComplexity));
DocumentValidator::addRule(
new DisableIntrospection((int) $this->introspectionConfig->isIntrospectionDisabled())
);
DocumentValidator::addRule(new QueryDepth($this->queryDepth));
}
}