-
-
Notifications
You must be signed in to change notification settings - Fork 564
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
Serializes \UnitEnum
and \BackedEnum
in GraphQL\Type\Definition\EnumType
when resolving return values from a Query or Mutation
#1608
Conversation
…PhpEnumType` resolving return values from a Query or Mutation
\UnitEnum
and \BackedEnum
in GraphQL\Type\Definition\PhpEnumType
resolving return values from a Query or Mutation\UnitEnum
and \BackedEnum
in GraphQL\Type\Definition\PhpEnumType
when resolving return values from a Query or Mutation
Have you seen #1604? |
\UnitEnum
and \BackedEnum
in GraphQL\Type\Definition\PhpEnumType
when resolving return values from a Query or Mutation\UnitEnum
and \BackedEnum
in GraphQL\Type\Definition\EnumType
when resolving return values from a Query or Mutation
Yes, but returning a native PHP enum from a resolver with the schema first approach still fails. I've updated the tests to use SDL for creating the schema and they both fail without the changes to |
@spawnia mind having another look at this pull request? |
Released with https://github.com/webonyx/graphql-php/releases/tag/v15.14.0. Please consider sponsoring. |
Since PHP has had native enums since version 8.1, there is an annoyance of not being able to return a native enum as a result from a query or mutation. If this is the case, it would have to be handled to return a string either by doing
MyEnum::A->name
orMyEnum::A->value
depending on if it's a backed or unit enum.This is also a bit of a nuisance if one uses DTOs for returning the data, as the type would have to be a string instead of being an enum which mirrors the enum in the GraphQL schema.
This pull request should address these issues by serializing native PHP enums if they were to be returned from a query or mutation.