I want to send parameter as object in Graphql but Internal server error occurs. For Reference i have attached graph query and error generated screenshot. I have also attached model and schema.graphql file's data and path.
Graphql Query and Error : https://i.imgur.com/OEwF4EA.png
Vendor\Module\etc\schema.graphqls
type Query {
Getproductbyid(input: Getbyidinput!): Getbyidoutput @resolver(class: "\\Vendor\\Module_name\\Model\\Resolver\\setproductwebp") @doc(description:"Contact us form")
}
@doc (description:"Get Product Value By Sku.......")
input Getbyidinput {
sku : String
base64_encoded_data : String
type : String
name : String
}
type Getbyidoutput {
message :String
}
Vendor\Module\Model\Resolver\Setproductwebp.php
<?php
namespace Vendor\Module\Model\Resolver;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
use Magento\Email\Model\Template\Filter;
use Magento\Catalog\Model\Product\Gallery\GalleryManagement;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Api\ImageContentValidatorInterface;
use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface;
use Magento\Framework\Exception\InputException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Exception\StateException;
class Setproductwebp implements ResolverInterface
{
private $helperapi;
private $helpercustomer;
private $filter;
public function __construct(
GalleryManagement $gallery,
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface $entry,
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
Data $helper,
ImageContentValidatorInterface $contentValidator,
\Magento\Framework\Api\Data\ImageContentInterface $imageContentInterface
) {
$this->gallery = $gallery;
$this->entry=$entry;
$this->productRepository = $productRepository;
$this->imageContentInterface=$imageContentInterface;
$this->contentValidator = $contentValidator;
}
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
{
try {
$sku = $args['input']['sku'];
$base64_encoded_data=$args['input']['base64_encoded_data'];
$type=$args['input']['type'];
$name=$args['input']['name'];
$entry = array("content" => array("base64_encoded_data"=> $base64_encoded_data, "type"=> $type, "name"=> $name));
$storeManager->info(print_r($entry,true));
$result = $this->gallery->create($sku,$entry);
$output = ['message' => 'Webp Image uploaded' ];
}
catch (\Exception $exception)
{
$output['message'] = "not work";
return $output;
}
}
}