-
Notifications
You must be signed in to change notification settings - Fork 225
Hi,
Just something that could make it easier to spot issues (with tools such as Psalm for example) and help with refactoring, there are attributes that take GraphQL type names, it would be nice to also be able to reference the type by their FQCN, e.g.:
#[GQL\Type] final class User { public function __construct( #[GQL\Field(type: 'ID!')] public readonly string $id, ) {} } #[GQL\Provider] final class UserExtension { #[GQL\Query( target User::class, // instead of targetType: 'User' )] public function one(): int { return 1; } }
All reactions
Replies: 1 comment 1 reply
Hi again @mathroc!
We cannot do that because we are targeting a GraphQL Type while you would like to target a PHP Class.
When working with annotations / attributes, we have this mapping (ie. 1 GraphQL Type = 1 PHP Class) so it would work.
But it would not with other mapping technics (like yaml which is still widely used).
Still, in this context, I guess we could allow both, detect if the target contains \ and try to guess the associated type using the ClassesTypesMap.
All reactions
Still, in this context, I guess we could allow both, detect if the target contains \ and try to guess the associated type using the ClassesTypesMap.
yes could be that or a separate argument for FQCNs. And, obviously, it would only work for type that comes from a PHP class