Skip to content

Commit

Permalink
Compare raw attributes only when ensuring uniqueness of paginated rel…
Browse files Browse the repository at this point in the history
…ated models
  • Loading branch information
jaulz authored May 1, 2024
1 parent 3f20ff1 commit dd2b859
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ You can find and compare releases at the [GitHub release page](https://github.co

## Unreleased

### Changed

- Compare raw attributes only when ensuring uniqueness of paginated related models https://github.com/nuwave/lighthouse/pull/2540

## v6.36.1

### Fixed
Expand Down
3 changes: 2 additions & 1 deletion src/Execution/ModelsLoader/PaginatedModelsLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Nuwave\Lighthouse\Pagination\PaginationArgs;
use Nuwave\Lighthouse\Pagination\ZeroPerPageLengthAwarePaginator;
use Nuwave\Lighthouse\Support\Utils;
use function Safe\json_encode;

class PaginatedModelsLoader implements ModelsLoader
{
Expand Down Expand Up @@ -84,7 +85,7 @@ protected function loadRelatedModels(EloquentCollection $parents): EloquentColle
return $relatedModels->unique(
// Compare all attributes because there might not be a unique primary key
// or there could be differing pivot attributes.
static fn (Model $relatedModel): string => $relatedModel->toJson(),
static fn (Model $relatedModel): string => json_encode($relatedModel->getOriginal()),
);
}

Expand Down

0 comments on commit dd2b859

Please sign in to comment.