Conditions | 3 |
Paths | 4 |
Total Lines | 22 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
13 | function execute(): ?array |
||
14 | { |
||
15 | $operation = $this->context->getOperation()->getOperation(); |
||
16 | $schema = $this->context->getSchema(); |
||
17 | |||
18 | $objectType = ($operation === 'mutation') |
||
19 | ? $schema->getMutation() |
||
20 | : $schema->getQuery(); |
||
21 | |||
22 | $fields = $this->collectFields($objectType, $this->operation->getSelectionSet(), new \ArrayObject(), new \ArrayObject()); |
||
23 | $path = []; |
||
24 | |||
25 | try { |
||
26 | $data = $this->executeFields($objectType, $this->rootValue, $path, $fields); |
||
27 | } catch (\Exception $ex) { |
||
28 | $this->context->addError( |
||
29 | new GraphQLError($ex->getMessage()) |
||
30 | ); |
||
31 | return null; |
||
32 | } |
||
33 | |||
34 | return $data; |
||
35 | } |
||
37 |