-
-
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
Pass custom serialize function to EnumType via config #775
Comments
In Lighthouse, we have extended the
I hope that gives you some idea on how you can implement such a type yourself. |
Thank you for quick answer! I think you lost me (or me you) :-) I have a schema file $schema = BuildSchema::build($schemaFile, TypeConfigDecorator::resolve()); After which I run the It might be worth to mention that I can override scalars in the TypeConfigDecorator with serialize, parseValue, parseLiteral functions that override the original function. |
I suppose that what you are trying to do is not possible with the type config decorator. It looks like the reference implementation does not support passing a custom Let's turn this into a feature request then, since I do think it is reasonable. I do like functional composition over inheritance anyways. Do you care enough to try and implement a PR? |
Thank you for your reply. Let me take a look at it in the coming days and I can come back with my findings on this thread. |
For anyone just using this project.. using @spawnia 's pattern above this is a simple extended class to handle this:
|
Is it possible to have custom enum types, like myclabs/php-enum?
It is possible via TypeConfigDecorator to replace enum values with php-enum, but the
serialize
function is not overridden from what I can see. Theserialize
function is never invoked, instead the default serialize function in EnumType is run. So I guess the question is how I can serialize custom enum types?The text was updated successfully, but these errors were encountered: