Conditions | 5 |
Paths | 8 |
Total Lines | 27 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
22 | public function executeFields(ObjectType $parentType, $rootValue, array $path, array $fields) |
||
23 | { |
||
24 | $results = []; |
||
25 | $doesContainPromise = false; |
||
26 | |||
27 | foreach ($fields as $fieldName => $fieldNodes) { |
||
28 | $fieldPath = $path; |
||
29 | $fieldPath[] = $fieldName; |
||
30 | |||
31 | try { |
||
32 | $result = $this->resolveField($parentType, $rootValue, $fieldNodes, $fieldPath); |
||
33 | } catch (UndefinedFieldException $exception) { |
||
34 | continue; |
||
35 | } |
||
36 | |||
37 | $doesContainPromise = $doesContainPromise || $result instanceof PromiseInterface; |
||
38 | $results[$fieldName] = $result; |
||
39 | } |
||
40 | |||
41 | if (!$doesContainPromise) { |
||
42 | return $results; |
||
43 | } |
||
44 | |||
45 | // Otherwise, results is a map from field name to the result of resolving that |
||
46 | // field, which is possibly a promise. Return a promise that will return this |
||
47 | // same map, but with any promises replaced with the values they resolved to. |
||
48 | return promiseForMap($results); |
||
49 | } |
||
51 |