10
10
use Magento \Catalog \Model \Product ;
11
11
use Magento \Catalog \Helper \ImageFactory as CatalogImageHelperFactory ;
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
use Magento \Store \Model \StoreManagerInterface ;
18
17
19
18
/**
20
- * Returns product image.
19
+ * Return product image paths by image type .
21
20
*/
22
21
class ProductImage implements ResolverInterface
23
22
{
@@ -26,28 +25,20 @@ class ProductImage implements ResolverInterface
26
25
*/
27
26
private $ catalogImageHelperFactory ;
28
27
29
- /**
30
- * @var ValueFactory
31
- */
32
- private $ valueFactory ;
33
-
34
28
/**
35
29
* @var StoreManagerInterface
36
30
*/
37
31
private $ storeManager ;
38
32
39
33
/**
40
- * @param ValueFactory $valueFactory
41
34
* @param CatalogImageHelperFactory $catalogImageHelperFactory,
42
35
* @param StoreManagerInterface $storeManager
43
36
*/
44
37
public function __construct (
45
- ValueFactory $ valueFactory ,
46
38
CatalogImageHelperFactory $ catalogImageHelperFactory ,
47
39
StoreManagerInterface $ storeManager
48
40
)
49
41
{
50
- $ this ->valueFactory = $ valueFactory ;
51
42
$ this ->catalogImageHelperFactory = $ catalogImageHelperFactory ;
52
43
$ this ->storeManager = $ storeManager ;
53
44
}
@@ -63,13 +54,9 @@ public function resolve(
63
54
ResolveInfo $ info ,
64
55
array $ value = null ,
65
56
array $ args = null
66
- ): Value
67
- {
57
+ ) {
68
58
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 ' ));
73
60
}
74
61
/** @var Product $product */
75
62
$ product = $ value ['model ' ];
@@ -88,10 +75,6 @@ public function resolve(
88
75
'path ' => $ product ->getData ($ imageType )
89
76
];
90
77
91
- $ result = function () use ($ imageData ) {
92
- return $ imageData ;
93
- };
94
-
95
- return $ this ->valueFactory ->create ($ result );
78
+ return $ imageData ;
96
79
}
97
- }
80
+ }
0 commit comments