GraphQL Doctrine PHP Enum Arrays
API Platform version(s) affected: x.y.z 3.2.17
Description
Fields mapped as SIMPLE_ARRAY get converted to paginated Collection instead of array, and are not even normalized.
Fields mapped as JSON get converted to array and are normalized correctly, however appear as untyped Iterable in graphQL schema.
Just returning "[EMyEnum]" in TypeConverter does not work.
return new ListOfType($this->resolveType("EMyEnum"));
works in introspection, but fails in normalization.
For the correct normalization I had to inject TypesContainer and use
if($this->typesContainer->has("EMyEnum")){
return new ListOfType($this->resolveType("EMyEnum"));
}
But it still doesn't work in denormalization: gets denormalized to strings instead of enums, and I had to convert each field in a MutationResolver manually.
How to reproduce
enum EMy string {
case Foo = 'foo';
case Bar = 'bar';
}
...
/** @var Array<int, EMy> */
#[ORM\Column(type: Types::JSON, enumType: EMy::class)]
public array $myEnums = [];
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.