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.sstatic.net/fdgZd.png


    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


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->productRepository = $productRepository;
        $this->contentValidator = $contentValidator;

    public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
        try {
            $sku = $args['input']['sku'];
            $entry = array("content" => array("base64_encoded_data"=> $base64_encoded_data, "type"=> $type, "name"=> $name));

             $result = $this->gallery->create($sku,$entry);
             $output = ['message' => 'Webp Image uploaded' ];

        catch (\Exception $exception)
            $output['message'] = "not work";
            return $output;

1 Answer 1


As I checked below the line in your code is causing the issue

$result = $this->gallery->create($sku,$entry);

Here you are trying to create a product gallery image programmatically. Here


the function expects argument two to be the type of


but you are passing an array to it, which is causing a type error issue.

Please check this link for reference to programmatically create a product image. Thanks! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.