You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We started migration to Apollo 1.0.5 (from 0.51.2), we ran the apollo-ios-cli code generation tool and then we got several compiler errors because the new tool generated a Swift enum where the cases names differs from what the 0.51.2 code generation tool generates.
If the graphql enum case name contains all uppercase letters and numbers (e.g BEFORE1940) then only the first letter of the generated Swift enum case is lowercased (.bEFORE1940) , all the other letters remains uppercased. Apollo 0.51.2 code generation would lowercase all the letters of the enum case name (.before1940).
publicenumHomeConstructionPeriod:RawRepresentable,Equatable,Hashable,CaseIterable,Apollo.JSONDecodable,Apollo.JSONEncodable{publictypealiasRawValue=Stringcase before1940
case before1970
case decade1940
case decade1950
case decade1960
case decade1970
case decade1980
case decade1990
case decade2000
case decade2010
case decade2020
case unknown
// ... Other code omitted ...}
Logs
No response
Anything else?
Our naming convention for graphql enums is using snake_case with UPPERCASED words for the cases (e.g. GENERIC_ERROR). In the Swift codebase we follow the classic lowercase words and camelCase (e.g. .genericError).
All the other generated Swift enums are consistent between Apollo 1.0.5 and 0.51.2, with lowercased words and camelCase. The enum reported above is the only one we have that also contains numbers and the only one that presents the described issue with the code generation.
The text was updated successfully, but these errors were encountered:
Hi @calvincestari, thanks for the quick response. I tried regenerating the enum using the fix/enum-case-conversion-strategy branch you suggested, but sadly it didn't solve the issue. The generated enum is the same. I removed the old generated file and made sure to reinstall the CLI, the problem persists.
Summary
We started migration to Apollo 1.0.5 (from 0.51.2), we ran the apollo-ios-cli code generation tool and then we got several compiler errors because the new tool generated a Swift enum where the cases names differs from what the 0.51.2 code generation tool generates.
If the graphql enum case name contains all uppercase letters and numbers (e.g
BEFORE1940
) then only the first letter of the generated Swift enum case is lowercased (.bEFORE1940
) , all the other letters remains uppercased. Apollo 0.51.2 code generation would lowercase all the letters of the enum case name (.before1940
).Version
1.0.5
Steps to reproduce the behavior
Given the following graphql enum
Apollo 1.0.5 generates
While Apollo 0.51.2 generates
Logs
No response
Anything else?
Our naming convention for graphql enums is using snake_case with UPPERCASED words for the cases (e.g.
GENERIC_ERROR
). In the Swift codebase we follow the classic lowercase words and camelCase (e.g..genericError
).All the other generated Swift enums are consistent between Apollo 1.0.5 and 0.51.2, with lowercased words and camelCase. The enum reported above is the only one we have that also contains numbers and the only one that presents the described issue with the code generation.
The text was updated successfully, but these errors were encountered: