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

Add casing strategies for queries names and schema types #3201

Closed
iDylanK opened this issue Aug 21, 2023 · 5 comments
Closed

Add casing strategies for queries names and schema types #3201

iDylanK opened this issue Aug 21, 2023 · 5 comments
Labels
codegen Issues related to or arising from code generation enhancement Issues outlining new things we want to do or things that will make our lives as devs easier low-priority

Comments

@iDylanK
Copy link

iDylanK commented Aug 21, 2023

Use case

When using the following conversion strategies:

 "conversionStrategies":  {
      "enumCases": "camelCase",
      "fieldAccessors": "camelCase"
}

all queries and types are generated using snake case.

Furthermore, because of this all mocks are also generated using snake case.

In our swift codebase, we don't want to have to use any snake case objects.

Describe the solution you'd like

No response

@iDylanK iDylanK added the feature New addition or enhancement to existing solutions label Aug 21, 2023
@AnthonyMDev
Copy link
Contributor

It would be great if you could provide a sample of the generated code you are getting so we can make sure we're talking about the same things here.

We don't currently have a codegen feature to convert names of types. If the names of the types in your schema use snake_case, then it makes sense you are getting types with snake_case. This is definitely a reasonable feature request. Though it's not a high priority issue for us. If you would like to contribute a PR to add this functionality, we'd be happy to work with you and review it!

As for the queries themselves, I'm not quite sure what you're referring to currently. Our query names are generated based on the names of your query operations in your .graphql files. So you have complete control over the naming there.

@AnthonyMDev AnthonyMDev changed the title Add casing strategies for queries and types Add casing strategies for queries names and schema types Sep 15, 2023
@AnthonyMDev AnthonyMDev added this to the Minor Releases (1.x) milestone Sep 15, 2023
@AnthonyMDev AnthonyMDev added enhancement Issues outlining new things we want to do or things that will make our lives as devs easier codegen Issues related to or arising from code generation and removed feature New addition or enhancement to existing solutions labels Sep 15, 2023
@iDylanK
Copy link
Author

iDylanK commented Sep 30, 2023

A codegen feature that convert names of types would indeed be useful to us.

Furthermore we would like to be able to convert the MockObjects to CamelCase.
Our backend only supports snake_case. So we define our queries like this:

query getPlayedTrakcs (
    $id: String!
  ){
  playedTracks: played_tracks(
    id: $id
  ) {
     id
     name
  }
}

The Mock is generated as: played_track

@calvincestari
Copy link
Member

@iDylanK, the codegen engine is respecting the field alias name played_tracks to generate the model property name and corresponding type name. You could try using a value of camelCase for the options.conversionStrategies.fieldAccessors codegen configuration option. I believe it should work with the field alias and give you the camel case property name you want.

@AnthonyMDev
Copy link
Contributor

I'm closing this issue due to inactivity. If this is still unresolved, feel free to provide more information and we can re-open this, or create a new issue.

@AnthonyMDev AnthonyMDev closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2024
Copy link

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better.

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 enhancement Issues outlining new things we want to do or things that will make our lives as devs easier low-priority
Projects
None yet
Development

No branches or pull requests

3 participants