Skip to content

Commit

Permalink
Merge pull request #15573 from craftcms/feature/pt-2102-5x-graphql-pr…
Browse files Browse the repository at this point in the history
…oduct-image-format-webp-not-working

Fixed #15572 GQL not allowing overriding named transforms
  • Loading branch information
brandonkelly authored Aug 21, 2024
2 parents 5d2fd35 + fc8cd8e commit df40816
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Fixed a bug where Craft couldn’t be installed with existing project config files, if any plugins specified their schema version via `composer.json`. ([#15559](https://github.com/craftcms/cms/issues/15559))
- Fixed a bug where Money fields’ min, max, and default values weren’t being set to the correct currency. ([#15565](https://github.com/craftcms/cms/issues/15565), [#15566](https://github.com/craftcms/cms/pull/15566))
- Fixed a bug where PHP-originated Craft Console API requests weren’t timing out if the API was down. ([#15571](https://github.com/craftcms/cms/pull/15571))
- Fixed a bug where it wasn’t possible to override named transforms in GraphQL queries. ([#15572](https://github.com/craftcms/cms/issues/15572))

## 4.11.3 - 2024-08-13

Expand Down
12 changes: 5 additions & 7 deletions src/helpers/Gql.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,15 +400,13 @@ public static function prepareTransformArguments(array $arguments): array|string
{
unset($arguments['immediately']);

if (!empty($arguments['handle'])) {
$transform = $arguments['handle'];
} elseif (!empty($arguments['transform'])) {
$transform = $arguments['transform'];
} else {
$transform = $arguments;
// Remap handle to transform to work with image transform normalization
if (isset($arguments['handle'])) {
$arguments['transform'] = $arguments['handle'];
unset($arguments['handle']);
}

return $transform;
return $arguments;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/gql/ElementFieldResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,9 @@ public function assetTransformDataProvider(): array
[['width' => 200, 'height' => 200], ['width' => 200, 'height' => 200]],
[['width' => 400, 'height' => 200], ['width' => 400, 'height' => 200]],
[['width' => 200, 'height' => 500], ['width' => 200, 'height' => 500]],
[['width' => 200, 'height' => 200, 'handle' => 'testHandle'], ['handle' => 'testHandle']],
[['width' => 200, 'height' => 200, 'transform' => 'testHandle2'], ['handle' => 'testHandle2']],
// Overriding named transforms
[['width' => 200, 'height' => 200, 'handle' => 'testHandle'], ['handle' => null, 'width' => 200, 'height' => 200]],
[['width' => 200, 'height' => 200, 'transform' => 'testHandle2'], ['handle' => null, 'width' => 200, 'height' => 200]],
];
}
}

0 comments on commit df40816

Please sign in to comment.