You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
namespaceApp\Query;
useSafe\DateTimeImmutable;
useTheCodingMachine\GraphQLite\Annotations\Query;
class MyQuery
{
/** * @Query() */publicfunctionmyQuery(DateTimeImmutable$dateTimeImmutable): string
{
return'It does not works';
}
}
Reported issue:
For parameter $dateTimeImmutable, in App\Query::myQuery, cannot map class "Safe\DateTimeImmutable" to a known GraphQL input type. Check your TypeMapper configuration.
The text was updated successfully, but these errors were encountered:
You need to register a type mapper. This isn't a case of being hardcoded really. What's hardcoded here, is nothing more than a convenience for the PHP core \DateTimeImmutable class.
You're trying to use a custom class. And that's okay, but you need to tell GraphQLite how to handle that. I created a rather generic type mapper that's been working well for us. I suggested having it implemented into the core with a config option to take in a mapping. If this was completed, you'd have a very easy way to map this. It looks like it's scheduled for 4.1 now.
Here is the original issue with the code if you'd like to go ahead and implement using your own custom type mapper...
On a project I am using Safe along side of GraphQLite.
As of Safe 1.0.0
DateTimeImmutable
has been added to the library in order to overwrite some function that may failed "silently".The problem is that GraphQLite do not handle this type of
DateTime
. It looks like the FQSen is hardcoded there:graphqlite/src/Mappers/Root/BaseTypeMapper.php
Line 142 in dd08619
Example to reproduce the bug:
Reported issue:
The text was updated successfully, but these errors were encountered: