I’m just going to show a basic example because nothing works.
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 VendorModuleGraphQL;
use MagentoFrameworkGraphQlQueryResolverInterface;
use MagentoFrameworkGraphQlQueryResolverContextInterface;
use MagentoFrameworkGraphQlSchemaTypeResolveInfo;
use VendorModuleServiceEncryption as EncryptionService;
use MagentoFrameworkGraphQlConfigElementField;
/**
* Class TokenHash
* @package VendorModuleGraphQL
*/
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”
I can’t find any info on this, i’m doing exactly how it’s documented everywhere.