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

Cast backed enum to its value when return type is a 'leaf' #50

Merged
merged 1 commit into from
May 5, 2022

Conversation

ttrig
Copy link
Contributor

@ttrig ttrig commented May 3, 2022

tldr; Eloquent models casting enums was catched by the fieldFromArray (because of ArrayAccess) and the enum instance was returned instead of its value resulting in a "Expected a value of type "MyEnum" but received: instance of App\Enums\MyEnum" error.

@ttrig ttrig marked this pull request as ready for review May 3, 2022 18:33
@emil-nasso
Copy link
Contributor

emil-nasso commented May 4, 2022

Should we maybe add a test for something that is "fully wrapped"?

[String!]! => [$phpEnum]

Mostly to make sure that the recursion of getWrappedType works as we expect.

Edit: We don't have support for "converting" lists of php-enums to [String!]!. This would be considered a "bonus" in my eyes. Not needed for this PR.

@ttrig ttrig marked this pull request as draft May 4, 2022 09:04
@ttrig ttrig marked this pull request as ready for review May 4, 2022 14:04
@ttrig ttrig merged commit 0cf254c into master May 5, 2022
@ttrig ttrig deleted the more-enums branch May 5, 2022 08:14
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

Successfully merging this pull request may close these issues.

None yet

4 participants