Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
QueryProcessor.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
10 use GraphQL\Validator\DocumentValidator;
11 use GraphQL\Validator\Rules\DisableIntrospection;
12 use GraphQL\Validator\Rules\QueryDepth;
16 
21 {
25  private $exceptionFormatter;
26 
30  public function __construct(ExceptionFormatter $exceptionFormatter)
31  {
32  $this->exceptionFormatter = $exceptionFormatter;
33  }
34 
45  public function process(
47  string $source,
48  ContextInterface $contextValue = null,
49  array $variableValues = null,
50  string $operationName = null
51  ) : array {
52  if (!$this->exceptionFormatter->shouldShowDetail()) {
53  DocumentValidator::addRule(new QueryDepth(10));
54  DocumentValidator::addRule(new DisableIntrospection());
55  }
56  $rootValue = null;
57  return \GraphQL\GraphQL::executeQuery(
58  $schema,
59  $source,
60  $rootValue,
61  $contextValue,
62  $variableValues,
63  $operationName
64  )->toArray(
65  $this->exceptionFormatter->shouldShowDetail() ?
66  \GraphQL\Error\Debug::INCLUDE_DEBUG_MESSAGE | \GraphQL\Error\Debug::INCLUDE_TRACE : false
67  );
68  }
69 }
return false
Definition: gallery.phtml:36
__construct(ExceptionFormatter $exceptionFormatter)
$source
Definition: source.php:23
process(Schema $schema, string $source, ContextInterface $contextValue=null, array $variableValues=null, string $operationName=null)