apollographql / apollographql/apollo-tooling
[codegen][swift] code generation issue on `init` enum case
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
**Intended outcome:**
On swift code generation, when schema contains an enumeration with the word `init`, the swift generated code failed to build since init is a reserved word.
**Actual outcome:**
On schema, an enumeration declared like this :
```graphql
enum CEventType {
init
addUser
removeUser
}
```
When the swift code is generated, except for the enum case, there is no escaping put on the word `init` for init method, rawValue, equatable protocole and allCases implementation.

An issue has been closed on the apollo-ios repository since it's appear to be an issue in the codegen part. https://github.com/apollographql/apollo-ios/issues/1427
Since the current API I use is on a production environment it appear to be difficult to change the name of the enum, so I hope you can get look on this. Thanks.
**How to reproduce**
Create schema with the given enum and generate the swift code and try to build.
**Versions**
The version used to reproduce this bug is the Apollo-tooling version included in the apollo-ios library run script. Here I use the version 0.43.0 of `apollo-ios` library (through cocoapods) that seems to use `apollo-tooling` version 2.32.1
Contributor guide
Research direction
Start in the Apollo tooling Swift code-generation path and reproduce the issue with the provided CEventType schema using Apollo tooling 2.32.1. Done means every generated use of the init enum case, including the initializer, rawValue, Equatable, and allCases implementations, is escaped so the Swift output builds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100