Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL Doctrine PHP Enum Arrays #6336

Open
AlgronovM opened this issue Apr 28, 2024 · 0 comments
Open

GraphQL Doctrine PHP Enum Arrays #6336

AlgronovM opened this issue Apr 28, 2024 · 0 comments

Comments

@AlgronovM
Copy link

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 = [];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant