Skip to content

Commit

Permalink
Update paginatators logic
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvanassche committed Apr 4, 2024
1 parent e6f82ef commit 4d5ee82
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Resolvers/TransformedDataCollectableResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,16 @@ protected function transformPaginator(
Wrap $wrap,
TransformationContext $nestedContext,
): array {
$items = array_map(fn (BaseData $data) => $this->transformationClosure($nestedContext)($data), $paginator->items());

if ($nestedContext->transformValues === false) {
return $items;
return $paginator->map(fn (BaseData $data) => $this->transformationClosure($nestedContext)($data))->all();
}

$paginated = $paginator->toArray();

$wrapKey = $wrap->getKey() ?? 'data';

return [
$wrapKey => $items,
$wrapKey => array_map(fn (BaseData $data) => $this->transformationClosure($nestedContext)($data), $paginator->items()),
'links' => $paginated['links'] ?? [],
'meta' => Arr::except($paginated, [
'data',
Expand Down

0 comments on commit 4d5ee82

Please sign in to comment.