Skip to content

Commit

Permalink
Updates $onAssetElementList check to handle arrays
Browse files Browse the repository at this point in the history
I'm not sure _exactly_ why the `$value` here is sometimes an array, but my best guess is that when a relation field is used twice, the second time it comes through as an array instead of a collection.

Fixes #11982
  • Loading branch information
brianjhanson committed Sep 21, 2022
1 parent 5ac4d0a commit 96b6a0c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/gql/directives/Transform.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static function name(): string
public static function apply(mixed $source, mixed $value, array $arguments, ResolveInfo $resolveInfo): mixed
{
$onAssetElement = $value instanceof Asset;
$onAssetElementList = $value instanceof Collection && !$value->isEmpty();
$onAssetElementList = ($value instanceof Collection && !$value->isEmpty()) || (is_array($value) && !empty($value));
$onApplicableAssetField = $source instanceof Asset && in_array($resolveInfo->fieldName, ['height', 'width', 'url']);

if (!($onAssetElement || $onAssetElementList || $onApplicableAssetField) || empty($arguments)) {
Expand Down

0 comments on commit 96b6a0c

Please sign in to comment.