Named UnionTypes
Description
Hey everyone, I am migrating a codebase from pure webonyx to your library. I am trying to keep the schemas 1-to-1 to avoid breaking changes. I think I am covered on everything with your awesome, except one thing. I haven't figured out the way to name the union types 😅 .
As I understand you build them on the fly by figuring out the PHP return type
Is there a way to actually name the union tho?
AFAIK, there's no way to configure a name for concrete unions, but you can inject your own naming strategy [1] in the GraphQL schema factory [2]. In your strategy, you can do whatever you want in getUnionTypeName method implementation [3].
But it can be considered as a valid feature request - be able to hint union type name in the codebase with attributes.
[1] \TheCodingMachine\GraphQLite\NamingStrategyInterface
[2] \TheCodingMachine\GraphQLite\SchemaFactory::setNamingStrategy
[3] \TheCodingMachine\GraphQLite\NamingStrategyInterface::getUnionTypeName
Yea, there isn't a way to do this at the moment. Seems more fitting as an interface to me though, if you have a concrete name for a thing, instead of the union of two things. I guess a union alias is just shortcut of sorts.