-
Notifications
You must be signed in to change notification settings - Fork 722
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
GraphQL enum type with values that are reserved Swift keywords #53
Comments
There's a closed issue on this here: apollographql/apollo-tooling#33 Edit: Seems to work for property names but maybe was missed for enum cases |
@MrAlek I guess it's missed. I am on |
Ah, that should be pretty easy to fix actually! Swift allows you to escape identifiers by using backticks. So in this case, you'd want the output to be: /// The privacy modes for an album.
public enum AlbumPrivacies: String {
case `public` = "PUBLIC" /// Public albums can be joined and viewed by anyone.
case `private` = "PRIVATE" /// Private albums can be joined and viewed only with an invitation.
} Unfortunately, it seems apollographql/apollo-tooling#33 doesn't take enum cases into account. But that should be a single line fix because the |
@martijnwalraven any estimates on when the fix could make it to |
@attheodo: Working on it right now, give me 15 min :) |
@martijnwalraven you Sir are awesome! Thanks! |
@attheodo: Should be fixed in |
That's an interesting case. Our GraphQL backend has an
AlbumPrivacies
enum with valuesPRIVATE
andPUBLIC
.Reasonably, Apollo tries to generate the respective Swift enum in the following way:
Unfortunately,
public
andprivate
are of course reserved Swift keywords so unfortunately the generated code is broken.I am not sure what's the most appropriate way to mitigate this on your side. Maybe check whether an enum value is a reserved keyword and prefix/suffix something to its name declaration? So in that case it could be
publicCase
andprivateCase
or something.Just thinking out loud here.
The text was updated successfully, but these errors were encountered: