Graphql Base Resolver Class.
Here is the base resolver class in graphql in magento 2.
<?php
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,
$context,
ResolveInfo $info,
array $value = null,
array $args = null
) {
if (!isset($args['post_id']) || empty($args['post_id'])) {
throw new GraphQlInputException(__('Invalid Data.'));
}
return $this;
}
}