-
-
Notifications
You must be signed in to change notification settings - Fork 565
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
Don't try parse value as string if it's already enum unit. PhpEnumType #1481
Conversation
Not sure I totally follow what you're up to, here, but if it makes any difference there's a PR pending that refactors the |
I'm sure there won't be any problems with this. I saw this PR. Only one method from the parent class is added here. I’m sure that the merger with your PR will take place without conflicts, but even if there are conflicts, it can be solved. |
@@ -9,6 +9,10 @@ You can find and compare releases at the [GitHub release page](https://github.co | |||
|
|||
## Unreleased | |||
|
|||
### Fixed | |||
|
|||
- Fix PhpEnumType parse value if it's already enum value https://github.com/webonyx/graphql-php/pull/1481 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Fix PhpEnumType parse value if it's already enum value https://github.com/webonyx/graphql-php/pull/1481 | |
- Handle enum values in `PhpEnumType::parseValue()` https://github.com/webonyx/graphql-php/pull/1481 |
'extensions' => [ | ||
'debugMessage' => 'Expected a value of type SimpleEnum but received: "WRONG". Cannot serialize value as enum: "WRONG"', | ||
'trace' => [ | ||
['call' => 'GraphQL\Type\Definition\EnumType::serialize()'], | ||
['call' => 'GraphQL\Type\Definition\EnumType::serialize(\'WRONG\')'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this fails in lower PHP versions - see https://github.com/webonyx/graphql-php/actions/runs/6914711109/job/19325221423?pr=1481. Not sure why it failed for you anyways, we are testing on PHP 8.2 in CI?
Fixes a bug in subscriptions when an enum object is received instead of a string
I added a couple of tests to check how the value is parsed.
In addition, I fix a test that fails depending on the PHP version (
tests/Type/EnumTypeTest.php@testAllowsSimpleArrayAsValues
). It might be worth using a check that does not include things that may change depending on the php version.All test passed. Tested with PHP 8.2.10 (cli) (built: Aug 31 2023 18:52:55) (NTS)
If we talk about the backward compatibility of these changes, then nothing should break.