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
VendorModuleetcschema.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
}
VendorModuleModelResolverSetproductwebp.php
<?php
namespace VendorModuleModelResolver;
use MagentoFrameworkGraphQlExceptionGraphQlInputException;
use MagentoFrameworkGraphQlExceptionGraphQlNoSuchEntityException;
use MagentoFrameworkGraphQlQueryResolverInterface;
use MagentoFrameworkGraphQlConfigElementField;
use MagentoFrameworkGraphQlSchemaTypeResolveInfo;
use MagentoEmailModelTemplateFilter;
use MagentoCatalogModelProductGalleryGalleryManagement;
use MagentoFrameworkAppFilesystemDirectoryList;
use MagentoFrameworkApiImageContentValidatorInterface;
use MagentoCatalogApiDataProductAttributeMediaGalleryEntryInterface;
use MagentoFrameworkExceptionInputException;
use MagentoFrameworkExceptionNoSuchEntityException;
use MagentoFrameworkExceptionStateException;
class Setproductwebp implements ResolverInterface
{
private $helperapi;
private $helpercustomer;
private $filter;
public function __construct(
GalleryManagement $gallery,
MagentoCatalogApiDataProductAttributeMediaGalleryEntryInterface $entry,
MagentoCatalogApiProductRepositoryInterface $productRepository,
Data $helper,
ImageContentValidatorInterface $contentValidator,
MagentoFrameworkApiDataImageContentInterface $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;
}
}
}