I have etc/schema.graphqls with the following example:
type Query{
fiservGenerateTokenHash: TokenHash @resolver(class: "Vendor\\Module\\GraphQL\\TokenHash")
}
I then have the TokenHash resolver
<?php
namespace Vendor\Module\GraphQL;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
use Vendor\Module\Service\Encryption as EncryptionService;
use Magento\Framework\GraphQl\Config\Element\Field;
/**
* Class TokenHash
* @package Vendor\Module\GraphQL
*/
class TokenHash implements ResolverInterface
{
/**
* @param EncryptionService $_encriptionService
*/
public function __construct( private readonly EncryptionService $_encriptionService
)
{
}
/**
* @param Field $field
* @param ContextInterface $context
* @param ResolveInfo $info
* @param array|null $value
* @param array|null $args
* @return array
*/
public function resolve(Field $field, $context, ResolveInfo $info, array $value =null, array $args = null)
{
$tokenHash = $this->_encryptionService->generateNewHashBySessionId();
return ['token'=>$tokenHash];
}
}
Now, when i run the basic test in postman to https://mydomain.com/graphql:
query {
fiservGenerateTokenHash {
token
}
}
All i get is this error: Cannot query field "fiservGenerateTokenHash" on type "Query"
This is driving me insane, i can't see anything wrong here