Skip to content

Commit

Permalink
Improve batch reference resolver code example
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Jul 31, 2024
1 parent 9350e60 commit 30fedff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion docs/6/federation/reference-resolvers.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ final class Product implements BatchedEntityResolver
{
public function __invoke(array $representations): iterable
{
$products = ProductRepository::byIDs(Arr::pluck($representations, 'id'))->keyBy('id');
$ids = Arr::pluck($representations, 'id');

$products = ProductRepository::byIDs($ids)
->keyBy('id');

$result = [];
foreach ($representations as $key => $representation) {
Expand Down
5 changes: 4 additions & 1 deletion docs/master/federation/reference-resolvers.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ final class Product implements BatchedEntityResolver
{
public function __invoke(array $representations): iterable
{
$products = ProductRepository::byIDs(Arr::pluck($representations, 'id'))->keyBy('id');
$ids = Arr::pluck($representations, 'id');

$products = ProductRepository::byIDs($ids)
->keyBy('id');

$result = [];
foreach ($representations as $key => $representation) {
Expand Down

0 comments on commit 30fedff

Please sign in to comment.