Skip to content

Commit 854264d

Browse files
author
Valeriy Nayda
committed
GraphQL-140: Added HTML renderer for description and short description
1 parent 506c148 commit 854264d

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

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

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010
use Magento\Catalog\Model\Product;
1111
use Magento\Framework\GraphQl\Config\Element\Field;
12-
use Magento\Framework\GraphQl\Query\Resolver\Value;
13-
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
12+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1413
use Magento\Framework\GraphQl\Query\ResolverInterface;
1514
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1615
use Magento\Catalog\Helper\Output as OutputHelper;
@@ -20,53 +19,38 @@
2019
*/
2120
class ProductHtmlAttribute implements ResolverInterface
2221
{
23-
/**
24-
* @var ValueFactory
25-
*/
26-
private $valueFactory;
27-
2822
/**
2923
* @var OutputHelper
3024
*/
3125
private $outputHelper;
3226

3327
/**
34-
* @param ValueFactory $valueFactory
3528
* @param OutputHelper $outputHelper
3629
*/
3730
public function __construct(
38-
ValueFactory $valueFactory,
3931
OutputHelper $outputHelper
4032
) {
41-
$this->valueFactory = $valueFactory;
4233
$this->outputHelper = $outputHelper;
4334
}
4435

4536
/**
46-
* {@inheritdoc}
37+
* @inheritdoc
4738
*/
4839
public function resolve(
4940
Field $field,
5041
$context,
5142
ResolveInfo $info,
5243
array $value = null,
5344
array $args = null
54-
): Value {
45+
) {
5546
if (!isset($value['model'])) {
56-
$result = function () {
57-
return null;
58-
};
59-
return $this->valueFactory->create($result);
47+
throw new GraphQlInputException(__('"model" value should be specified'));
6048
}
6149

6250
/* @var $product Product */
6351
$product = $value['model'];
6452
$fieldName = $field->getName();
6553
$renderedValue = $this->outputHelper->productAttribute($product, $product->getData($fieldName), $fieldName);
66-
$result = function () use ($renderedValue) {
67-
return $renderedValue;
68-
};
69-
70-
return $this->valueFactory->create($result);
54+
return $renderedValue;
7155
}
7256
}

0 commit comments

Comments
 (0)