You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, currently we are switching a larger project from BenSampo/laravel-enum to native php enums. Now I'm facing the Issue that many nested morph relations wont work anymore since we use Enums for the morph type declaration in our schema. These enums are backed in php by BackedEnums which map to the acutal class name.
BenSampo/laravel-enums are stringable and resolve to their value when casted to a string. Because of that the NestedMorphTo ArgResolver works fine. Now, when using native enums, casts to string are no longer possible since native enums are not stringable. This results in an error in e.g. the NestedMorphTo ArgResolver:
//nuwave/lighthouse/src/Execution/Arguments/NestedMorphTo.php$morphToModel = $this->relation->createModelByType(
(string) $connectArgs->arguments['type']->value,
//arguments['type']->value is a BackedEnum, this results in://Object of class App\Enums\LinkableType could not be converted to string
);
Since Laravel already supports native Enums in many cases like QueryBuilder or Eloquent it seems consistent to me to support them in lighthouse's morph relations.
I would be happy to submit a PR if this is a desirable feature.
Cheers
Stefan
The text was updated successfully, but these errors were encountered:
Hi, currently we are switching a larger project from BenSampo/laravel-enum to native php enums. Now I'm facing the Issue that many nested morph relations wont work anymore since we use Enums for the morph type declaration in our schema. These enums are backed in php by BackedEnums which map to the acutal class name.
BenSampo/laravel-enums are stringable and resolve to their value when casted to a string. Because of that the NestedMorphTo ArgResolver works fine. Now, when using native enums, casts to string are no longer possible since native enums are not stringable. This results in an error in e.g. the NestedMorphTo ArgResolver:
Since Laravel already supports native Enums in many cases like QueryBuilder or Eloquent it seems consistent to me to support them in lighthouse's morph relations.
I would be happy to submit a PR if this is a desirable feature.
Cheers
Stefan
The text was updated successfully, but these errors were encountered: