Skip to content
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

Automatically convert camel case fields to snake case #87

Closed
jaulz opened this issue Jul 29, 2023 · 6 comments · Fixed by #120
Closed

Automatically convert camel case fields to snake case #87

jaulz opened this issue Jul 29, 2023 · 6 comments · Fixed by #120
Assignees
Labels
pkg: graphql scope: feat New feature or request
Milestone

Comments

@jaulz
Copy link

jaulz commented Jul 29, 2023

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
Copy link
Author

jaulz commented Jul 29, 2023

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
Copy link
Owner

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.

@LastDragon-ru LastDragon-ru added scope: feat New feature or request pkg: graphql labels Jul 29, 2023
@jaulz
Copy link
Author

jaulz commented Jul 29, 2023

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
Copy link
Owner

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

@LastDragon-ru
Copy link
Owner

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 LastDragon-ru added this to the Next milestone Jan 11, 2024
@LastDragon-ru LastDragon-ru self-assigned this Jan 11, 2024
@LastDragon-ru
Copy link
Owner

LastDragon-ru commented Jan 13, 2024

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,
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: graphql scope: feat New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants