Graphql Base Resolver Class. - Magesan

Graphql Base Resolver Class.

Graphql Base Resolver Class.

Here is the base resolver class in graphql in magento 2.


namespace Magesan\Extension\Model\Resolver;

use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;

class BaseResolver implements ResolverInterface
     * @inheritdoc
    public function resolve(
        Field $field,
        ResolveInfo $info,
        array $value = null,
        array $args = null
    ) {
        if (!isset($args['post_id']) || empty($args['post_id'])) {
            throw new GraphQlInputException(__('Invalid Data.'));

         return $this;

Leave a Reply

Your email address will not be published. Required fields are marked *.

You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>