Skip to content

Commit 277c81f

Browse files
committed
Updates
1 parent 0400e32 commit 277c81f

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Product/ProductImage.php

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
use Magento\Catalog\Model\Product;
1111
use Magento\Catalog\Helper\ImageFactory as CatalogImageHelperFactory;
1212
use Magento\Framework\GraphQl\Config\Element\Field;
13-
use Magento\Framework\GraphQl\Query\Resolver\Value;
14-
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
13+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1514
use Magento\Framework\GraphQl\Query\ResolverInterface;
1615
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1716
use Magento\Store\Model\StoreManagerInterface;
1817

1918
/**
20-
* Returns product image.
19+
* Return product image paths by image type.
2120
*/
2221
class ProductImage implements ResolverInterface
2322
{
@@ -26,28 +25,20 @@ class ProductImage implements ResolverInterface
2625
*/
2726
private $catalogImageHelperFactory;
2827

29-
/**
30-
* @var ValueFactory
31-
*/
32-
private $valueFactory;
33-
3428
/**
3529
* @var StoreManagerInterface
3630
*/
3731
private $storeManager;
3832

3933
/**
40-
* @param ValueFactory $valueFactory
4134
* @param CatalogImageHelperFactory $catalogImageHelperFactory,
4235
* @param StoreManagerInterface $storeManager
4336
*/
4437
public function __construct(
45-
ValueFactory $valueFactory,
4638
CatalogImageHelperFactory $catalogImageHelperFactory,
4739
StoreManagerInterface $storeManager
4840
)
4941
{
50-
$this->valueFactory = $valueFactory;
5142
$this->catalogImageHelperFactory = $catalogImageHelperFactory;
5243
$this->storeManager = $storeManager;
5344
}
@@ -63,13 +54,9 @@ public function resolve(
6354
ResolveInfo $info,
6455
array $value = null,
6556
array $args = null
66-
): Value
67-
{
57+
) {
6858
if (!isset($value['model'])) {
69-
$result = function () {
70-
return null;
71-
};
72-
return $this->valueFactory->create($result);
59+
throw new GraphQlInputException(__('"model" value should be specified'));
7360
}
7461
/** @var Product $product */
7562
$product = $value['model'];
@@ -88,10 +75,6 @@ public function resolve(
8875
'path' => $product->getData($imageType)
8976
];
9077

91-
$result = function () use ($imageData) {
92-
return $imageData;
93-
};
94-
95-
return $this->valueFactory->create($result);
78+
return $imageData;
9679
}
97-
}
80+
}

0 commit comments

Comments
 (0)