diff --git a/app/code/Magento/CatalogGraphQl/Model/Resolver/Category/CategoryHtmlAttribute.php b/app/code/Magento/CatalogGraphQl/Model/Resolver/Category/CategoryHtmlAttribute.php index 55c90425c2f5f..7ccb46c3a293f 100644 --- a/app/code/Magento/CatalogGraphQl/Model/Resolver/Category/CategoryHtmlAttribute.php +++ b/app/code/Magento/CatalogGraphQl/Model/Resolver/Category/CategoryHtmlAttribute.php @@ -8,9 +8,8 @@ namespace Magento\CatalogGraphQl\Model\Resolver\Category; use Magento\Catalog\Model\Category; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\GraphQl\Config\Element\Field; -use Magento\Framework\GraphQl\Query\Resolver\Value; -use Magento\Framework\GraphQl\Query\Resolver\ValueFactory; use Magento\Framework\GraphQl\Query\ResolverInterface; use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; use Magento\Catalog\Helper\Output as OutputHelper; @@ -20,25 +19,17 @@ */ class CategoryHtmlAttribute implements ResolverInterface { - /** - * @var ValueFactory - */ - private $valueFactory; - /** * @var OutputHelper */ private $outputHelper; /** - * @param ValueFactory $valueFactory * @param OutputHelper $outputHelper */ public function __construct( - ValueFactory $valueFactory, OutputHelper $outputHelper ) { - $this->valueFactory = $valueFactory; $this->outputHelper = $outputHelper; } @@ -51,12 +42,9 @@ public function resolve( ResolveInfo $info, array $value = null, array $args = null - ): Value { + ) { if (!isset($value['model'])) { - $result = function () { - return null; - }; - return $this->valueFactory->create($result); + throw new LocalizedException(__('"model" value should be specified')); } /* @var $category Category */ @@ -64,10 +52,6 @@ public function resolve( $fieldName = $field->getName(); $renderedValue = $this->outputHelper->categoryAttribute($category, $category->getData($fieldName), $fieldName); - $result = function () use ($renderedValue) { - return $renderedValue; - }; - - return $this->valueFactory->create($result); + return $renderedValue; } } diff --git a/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Image.php b/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Image.php index 49617c442eebd..6830aecb78f10 100644 --- a/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Image.php +++ b/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Image.php @@ -9,6 +9,7 @@ use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\ImageFactory; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\GraphQl\Config\Element\Field; use Magento\Framework\GraphQl\Query\ResolverInterface; use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; @@ -45,7 +46,7 @@ public function resolve( array $args = null ): array { if (!isset($value['model'])) { - throw new \LogicException(__('"model" value should be specified')); + throw new LocalizedException(__('"model" value should be specified')); } /** @var Product $product */ $product = $value['model'];