Skip to content

Commit 5a674c7

Browse files
committed
Making the resolver universal
1 parent c53bb4f commit 5a674c7

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Product/SmallImage.php renamed to app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Image.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@
1414
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
1515
use Magento\Framework\GraphQl\Query\ResolverInterface;
1616
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
17-
use Magento\Store\Model\StoreManagerInterface;
1817

1918
/**
20-
* Returns product's image. If the image is not set, returns a placeholder
19+
* Returns product's image. If the image is not set, returns a placeholder
2120
*/
22-
class SmallImage implements ResolverInterface
21+
class Image implements ResolverInterface
2322
{
2423
/**
2524
* @var CatalogImageHelperFactory
@@ -34,16 +33,13 @@ class SmallImage implements ResolverInterface
3433
/**
3534
* @param ValueFactory $valueFactory
3635
* @param CatalogImageHelperFactory $catalogImageHelperFactory
37-
* @param StoreManagerInterface $storeManager
3836
*/
3937
public function __construct(
4038
ValueFactory $valueFactory,
41-
CatalogImageHelperFactory $catalogImageHelperFactory,
42-
StoreManagerInterface $storeManager
39+
CatalogImageHelperFactory $catalogImageHelperFactory
4340
) {
4441
$this->valueFactory = $valueFactory;
4542
$this->catalogImageHelperFactory = $catalogImageHelperFactory;
46-
$this->storeManager = $storeManager;
4743
}
4844

4945
/**
@@ -57,10 +53,7 @@ public function resolve(
5753
array $args = null
5854
): Value {
5955
if (!isset($value['model'])) {
60-
$result = function () {
61-
return null;
62-
};
63-
return $this->valueFactory->create($result);
56+
throw new \LogicException(__("Cannot resolve entity model"));
6457
}
6558
/** @var Product $product */
6659
$product = $value['model'];

app/code/Magento/CatalogGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ interface ProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\
258258
meta_keyword: String @doc(description: "A comma-separated list of keywords that are visible only to search engines")
259259
meta_description: String @doc(description: "A brief overview of the product for search results listings, maximum 255 characters")
260260
image: String @doc(description: "The relative path to the main image on the product page")
261-
small_image: ProductImage @doc(description: "The relative path to the small image, which is used on catalog pages") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\SmallImage")
261+
small_image: ProductImage @doc(description: "The relative path to the small image, which is used on catalog pages") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\Image")
262262
thumbnail: String @doc(description: "The relative path to the product's thumbnail image")
263263
new_from_date: String @doc(description: "The beginning date for new product listings, and determines if the product is featured as a new product") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\NewFromTo")
264264
new_to_date: String @doc(description: "The end date for new product listings") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\NewFromTo")

0 commit comments

Comments
 (0)