STEP-4 Simple GraphQl and Resolver
The next few steps not going to be so visual, but very important, we going to create an Extension and establish the connection (communication) between this extension and our module.
Last updated
The next few steps not going to be so visual, but very important, we going to create an Extension and establish the connection (communication) between this extension and our module.
Last updated
type Query {
socialShare: socialShareType @resolver(class:"\\ScandiPWA\\SocialShareGraphQl\\Model\\Resolver\\SocialShare")
}
type socialShareType {
enabled: String
}
<?php
declare(strict_types=1);
namespace ScandiPWA\SocialShareGraphQl\Model\Resolver;
use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
use Magento\Framework\GraphQl\Query\Resolver\Value;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
use Magento\Framework\App\Config\ScopeConfigInterface;
/**
* @package ScandiPWA\SocialShareGraphQl\Model\Resolver
*/
class SocialShare implements ResolverInterface
{
/**
* @param Field $field
* @param ContextInterface $context
* @param ResolveInfo $info
* @param array|null $value
* @param array|null $args
* @return string[]
*/
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
{
$result = [
'enabled' => 'works'
];
return $result;
}
}