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

How to generate snake_case property name to camelCase in Apollo version 1.0.3 cli auto generate? #2641

Closed
Spatel91111 opened this issue Nov 4, 2022 · 8 comments
Labels
codegen Issues related to or arising from code generation feature New addition or enhancement to existing solutions
Milestone

Comments

@Spatel91111
Copy link

Spatel91111 commented Nov 4, 2022

How to generate snake_case property name to camelCase in 1.0.3 cli auto generate?

Configuration in .json file as below:

Screenshot 2022-11-04 at 4 43 00 PM

But generate property in mutation file as below

public var first_name: String { __data["first_name"] }

Need to generate property name like this

public var firstName: String { __data["first_name"] }

is it possible in Apollo 1.0.3 version?

@Spatel91111 Spatel91111 added the question Issues that have a question which should be addressed label Nov 4, 2022
@Spatel91111 Spatel91111 changed the title How to generate snake_case property name to camelCase in 1.0.3 cli auto generate? How to generate snake_case property name to camelCase in Apollo version 1.0.3 cli auto generate? Nov 4, 2022
@calvincestari
Copy link
Member

Hi @Spatel91111 👋🏻 - currently the conversion strategy is only for enum cases. It does not work for all properties yet, that is one of the future features we're considering. I'll add this to a future milestone for now.

@calvincestari calvincestari added feature New addition or enhancement to existing solutions codegen Issues related to or arising from code generation and removed question Issues that have a question which should be addressed labels Nov 5, 2022
@calvincestari calvincestari added this to the Release 1.1 milestone Nov 5, 2022
@calvincestari
Copy link
Member

In the same area as #2570.

@Spatel91111
Copy link
Author

Hello @calvincestari , is any update on this feature(convert snake_case property name to camelCase)?

@calvincestari
Copy link
Member

No progress yet, it's scheduled for one of the upcoming releases. We're always happy to accept and review PRs though, thanks.

@Spatel91111
Copy link
Author

Spatel91111 commented Dec 6, 2022

Thank you @calvincestari !!!

Now one more question : is it possible to generate model with class instead of struct via any configuration?

@AnthonyMDev
Copy link
Contributor

@Spatel91111, no these models are immutable and intended to be used as value structs. It provides a lot of performance benefit to use structs here. What reasons do you have for wanting them to be classes?

@Spatel91111
Copy link
Author

Spatel91111 commented Dec 7, 2022

@AnthonyMDev thank you for reply.

One scenario is that the model object goes beyond 3-4 level screens and the first screen needs to be updated accordingly because the structure object is passed by its value and the object value is not updated in the first screen.

@AnthonyMDev
Copy link
Contributor

The returned models are not updated in-place when your data is updated though. That's why they are immutable structs. When you get new data, you get completely new instances of your model objects, which you need to then pass to your views or some view model that can use the new data. Turning the models into classes would not change this.

Updating the models in-place would be a major change to the way Apollo works and is not something that is in scope for our current work. We do hope to provide better ways for you to receive updates to your data in a more fine grained way at some point, but I'm not sure what that will look like yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codegen Issues related to or arising from code generation feature New addition or enhancement to existing solutions
Projects
None yet
Development

No branches or pull requests

3 participants