LastDragon-ru / lara-asp

Awesome Set of Packages for Laravel
MIT License
11 stars 1 forks source link

Automatically convert camel case fields to snake case #87

Closed jaulz closed 9 months ago

jaulz commented 1 year ago

It would be great if there would be a way to automatically rename fields in the type that is used with the @searchBy directive to be in snake case. For example I would like to leave out the @rename column here:

input LegalEntityTypeFilters {
  title: String
  countryCode: String @rename(attribute: "country_code")
}

Or is there any nice way at the moment to already achieve it?

jaulz commented 1 year ago

While doing the mentioned renaming above, I noticed that it actually doesn't work like the way I thought. There is no filter applied eventually 🤔

LastDragon-ru commented 1 year ago

Or is there any nice way at the moment to already achieve it?

Nope...

There is no filter applied eventually 🤔

Strange. (1) Which version of the package are you using? (2) Do you see @rename in the final schema?

ps: You can also try https://github.com/itsgoingd/clockwork / https://laravel.com/docs/10.x/telescope to see queries.

jaulz commented 1 year ago

I am using 4.5.0 and actually just upgraded. However, I think I found where the value is lost:

image

The input is still country_code but the type's property is countryCode and hence the arguments are empty and the filter is not applied:

image
LastDragon-ru commented 1 year ago

Maybe you can create a small repo with the error? It will be very helpful for debug.

LastDragon-ru commented 1 year ago

I think I found where the value is lost:

Yep. I can reproduce it, but not sure how to fix yet. The bug extracted to #88.

LastDragon-ru commented 9 months ago

In upcoming v6 will be possible to define BuilderPropertyResolver and implement any conversion you want 😃

// AppProvider

$this->app->bind(
    LastDragon_ru\LaraASP\GraphQL\Builder\Contracts\BuilderPropertyResolver::class,
    MyBuilderPropertyResolver::class,
);