diff --git a/Model/GraphQLResolver/ProductAttributeCldResolver.php b/Model/GraphQLResolver/ProductAttributeCldResolver.php new file mode 100644 index 0000000..5520e6f --- /dev/null +++ b/Model/GraphQLResolver/ProductAttributeCldResolver.php @@ -0,0 +1,42 @@ +productGalleryManagement = $productGalleryManagement; + } + + /** + * @inheritdoc + */ + public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) + { + $productId = $value['sku']; + $productMediaStr = $this->productGalleryManagement->getProductMedia($productId); + $jsonDecoder = new \Magento\Framework\Serialize\Serializer\Json(); + $productMedia = $jsonDecoder->unserialize($productMediaStr); + return $productMedia['data']; + } + } \ No newline at end of file diff --git a/etc/schema.graphqls b/etc/schema.graphqls new file mode 100644 index 0000000..8d2e385 --- /dev/null +++ b/etc/schema.graphqls @@ -0,0 +1,12 @@ +type CloudinaryData { + image: String + small_image: String + thumbnail: String + media_gallery: [String] +} + +interface ProductInterface { + cld_data: CloudinaryData + @resolver(class: "\\Cloudinary\\Cloudinary\\Model\\GraphQLResolver\\ProductAttributeCldResolver") + @doc(description: "Cloudinary urls generated for product images") +} \ No newline at end of file