Total Complexity | 5 |
Total Lines | 24 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
23 | trait FieldsToAttributesTrait |
||
24 | { |
||
25 | /** |
||
26 | * Retrieves fields, recursively replaces the "_id" key (the raw id) by "id" (the name of the property expected by the Serializer) and flattens edge and node structures (pagination). |
||
27 | */ |
||
28 | private function fieldsToAttributes(ResolveInfo $info): array |
||
29 | { |
||
30 | $fields = $info->getFieldSelection(PHP_INT_MAX); |
||
31 | |||
32 | return $this->replaceIdKeys($fields['edges']['node'] ?? $fields); |
||
33 | } |
||
34 | |||
35 | private function replaceIdKeys(array $fields): array |
||
47 | } |
||
48 | } |
||
49 |