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

codegen: Add an option to capitalize acronyms when the first character is capitalized #3419

Open
tonyarnold opened this issue Jul 31, 2024 · 4 comments
Assignees
Labels
codegen Issues related to or arising from code generation feature New addition or enhancement to existing solutions

Comments

@tonyarnold
Copy link
Contributor

Use case

We use Nick Lockwood's excellent SwiftFormat tool, which includes an acronym rule that we'd like to use in our codebase that states the following:

Capitalize acronyms when the first character is capitalized.

Acronyms to auto-capitalize. Defaults to "ID,URL,UUID"

Currently, Apollo's codegen defaults to capitalising the first letter of an acronym, and then lowercasing the rest.

Describe the solution you'd like

We'd like to be able to configure Apollo's code generation to output acronyms in a format where the entire acronym is uppercased.

Thanks!

@tonyarnold tonyarnold added the feature New addition or enhancement to existing solutions label Jul 31, 2024
@AnthonyMDev AnthonyMDev added the codegen Issues related to or arising from code generation label Jul 31, 2024
@AnthonyMDev AnthonyMDev added this to the Minor Releases (1.x) milestone Jul 31, 2024
@AnthonyMDev
Copy link
Contributor

This sounds like a good addition to make. We can add it to our backlog, but we have a lot of other things to work on and it's probably not something we're going to realistically get to in the near future.

If you would like to make a contribution to the library, I'd be happy to discuss the design of this feature with you and point you in the right direction to get started on a PR though!

@tonyarnold
Copy link
Contributor Author

Thanks, I’d love to make a contribution — can you point me in the right direction, and I’ll have a look at what needs to happen?

@AnthonyMDev
Copy link
Contributor

Thanks @tonyarnold! If you want to contribute, start by checking out our Contributors Guide to understand a bit about the development process. You'll need to clone the apollo-ios-dev repo and make PRs there.

You'll need to add a new option to ApolloCodegenConfiguration.OutputOptions for this. I expect it would like something similar to the additionalInflectionRules feature. You can look at that for an idea of where to start.

I'd recommend starting with either an RFC or just a simple PR that updates the codegen configuration to add the option to the codegen configuration before you get too far on the actual implementation. That's the area we are going to be the most picky on, because we want to make sure that user-facing API is easy to understand and use and flexible enough to handle every use case we can come up with. After we have reached consensus on what the configuration looks like, then we can talk more about the implementation details.

If you dig into that a bit and have any questions, feel free to post them here. Or I'm happy to get on a call with you sometime and go through the code a bit. Thanks so much for being willing to contribute!

@tonyarnold
Copy link
Contributor Author

Sounds great — I've opened an initial PR to gather feedback on the configuration components, and we'll take it from there!

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

2 participants