10
10
use Magento \Catalog \Model \Product ;
11
11
use Magento \CatalogGraphQl \Model \Resolver \Product \ProductTextAttribute \FormatList ;
12
12
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 ;
15
14
use Magento \Framework \GraphQl \Query \ResolverInterface ;
16
15
use Magento \Framework \GraphQl \Schema \Type \ResolveInfo ;
17
16
@@ -25,26 +24,18 @@ class ProductTextAttribute implements ResolverInterface
25
24
*/
26
25
private $ formatList ;
27
26
28
- /**
29
- * @var ValueFactory
30
- */
31
- private $ valueFactory ;
32
-
33
27
/**
34
28
* @var string
35
29
*/
36
30
private $ defaultFormat = 'html ' ;
37
31
38
32
/**
39
- * @param ValueFactory $valueFactory
40
- * @param FormatList $formatFactory
33
+ * @param FormatList $formatList
41
34
*/
42
35
public function __construct (
43
- ValueFactory $ valueFactory ,
44
- FormatList $ formatFactory
36
+ FormatList $ formatList
45
37
) {
46
- $ this ->valueFactory = $ valueFactory ;
47
- $ this ->formatList = $ formatFactory ;
38
+ $ this ->formatList = $ formatList ;
48
39
}
49
40
50
41
/**
@@ -56,10 +47,9 @@ public function resolve(
56
47
ResolveInfo $ info ,
57
48
array $ value = null ,
58
49
array $ args = null
59
- ): Value {
50
+ ) {
60
51
if (!isset ($ value ['model ' ])) {
61
- $ result = [];
62
- return $ this ->valueFactory ->create ($ result );
52
+ throw new GraphQlInputException (__ ('"model" value should be specified ' ));
63
53
}
64
54
65
55
/* @var $product Product */
@@ -69,6 +59,6 @@ public function resolve(
69
59
$ format = $ this ->formatList ->create ($ formatIdentifier );
70
60
$ result = ['content ' => $ format ->getContent ($ product , $ fieldName )];
71
61
72
- return $ this -> valueFactory -> create ( $ result) ;
62
+ return $ result ;
73
63
}
74
64
}
0 commit comments