1 | <?php |
||
18 | class Processor extends BaseProcessor { |
||
19 | |||
20 | /** |
||
21 | * @var \Drupal\graphql\GraphQL\Execution\Reducer |
||
22 | */ |
||
23 | protected $requestReducer; |
||
24 | |||
25 | /** |
||
26 | * Processor constructor. |
||
27 | * |
||
28 | * @param \Youshido\GraphQL\Schema\AbstractSchema $schema |
||
29 | * @param $query |
||
30 | * @param array $variables |
||
31 | */ |
||
32 | public function __construct(AbstractSchema $schema, $query, array $variables = []) { |
||
49 | |||
50 | /** |
||
51 | * @param \Drupal\graphql\GraphQL\Execution\Visitor\VisitorInterface $visitor |
||
52 | * @param callable $callback |
||
53 | * |
||
54 | * @return null |
||
55 | */ |
||
56 | public function reduceRequest(VisitorInterface $visitor, callable $callback) { |
||
71 | |||
72 | /** |
||
73 | * @return array|mixed |
||
74 | */ |
||
75 | public function resolveRequest() { |
||
76 | $output = []; |
||
77 | |||
78 | // if (!$this->executionContext->hasErrors()) { |
||
|
|||
79 | try { |
||
80 | $operations = $this->executionContext->getRequest()->getAllOperations(); |
||
81 | |||
82 | foreach ($operations as $query) { |
||
83 | if ($result = $this->resolveQuery($query)) { |
||
84 | $output = array_replace_recursive($output, $result); |
||
85 | }; |
||
86 | } |
||
87 | |||
88 | // If the processor found any deferred results, resolve them now. |
||
89 | if (!empty($output) && (!empty($this->deferredResultsLeaf) || !empty($this->deferredResultsComplex))) { |
||
90 | try { |
||
91 | while ($resolver = array_shift($this->deferredResultsComplex)) { |
||
92 | $resolver->resolve(); |
||
93 | } |
||
94 | |||
95 | // Deferred scalar and enum fields should be resolved last to pick up |
||
96 | // as many as possible for a single batch. |
||
97 | while ($resolver = array_shift($this->deferredResultsLeaf)) { |
||
98 | $resolver->resolve(); |
||
99 | } |
||
100 | } |
||
101 | catch (ResolveException $exception) { |
||
102 | $this->executionContext->addError($exception); |
||
103 | } |
||
104 | finally { |
||
105 | $output = static::unpackDeferredResults($output); |
||
106 | } |
||
107 | } |
||
108 | } |
||
109 | catch (ResolveException $exception) { |
||
110 | $this->executionContext->addError($exception); |
||
111 | } |
||
112 | // } |
||
113 | |||
114 | return $output; |
||
115 | } |
||
116 | |||
117 | /** |
||
118 | * {@inheritdoc} |
||
119 | */ |
||
120 | protected function deferredResolve($resolvedValue, FieldInterface $field, callable $callback) { |
||
143 | |||
144 | } |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.