1010use Magento \Catalog \Model \Product ;
1111use Magento \CatalogGraphQl \Model \Resolver \Product \ProductTextAttribute \FormatList ;
1212use 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 ;
1514use Magento \Framework \GraphQl \Query \ResolverInterface ;
1615use Magento \Framework \GraphQl \Schema \Type \ResolveInfo ;
1716
@@ -25,26 +24,18 @@ class ProductTextAttribute implements ResolverInterface
2524 */
2625 private $ formatList ;
2726
28- /**
29- * @var ValueFactory
30- */
31- private $ valueFactory ;
32-
3327 /**
3428 * @var string
3529 */
3630 private $ defaultFormat = 'html ' ;
3731
3832 /**
39- * @param ValueFactory $valueFactory
40- * @param FormatList $formatFactory
33+ * @param FormatList $formatList
4134 */
4235 public function __construct (
43- ValueFactory $ valueFactory ,
44- FormatList $ formatFactory
36+ FormatList $ formatList
4537 ) {
46- $ this ->valueFactory = $ valueFactory ;
47- $ this ->formatList = $ formatFactory ;
38+ $ this ->formatList = $ formatList ;
4839 }
4940
5041 /**
@@ -56,10 +47,9 @@ public function resolve(
5647 ResolveInfo $ info ,
5748 array $ value = null ,
5849 array $ args = null
59- ): Value {
50+ ) {
6051 if (!isset ($ value ['model ' ])) {
61- $ result = [];
62- return $ this ->valueFactory ->create ($ result );
52+ throw new GraphQlInputException (__ ('"model" value should be specified ' ));
6353 }
6454
6555 /* @var $product Product */
@@ -69,6 +59,6 @@ public function resolve(
6959 $ format = $ this ->formatList ->create ($ formatIdentifier );
7060 $ result = ['content ' => $ format ->getContent ($ product , $ fieldName )];
7161
72- return $ this -> valueFactory -> create ( $ result) ;
62+ return $ result ;
7363 }
7464}
0 commit comments