-
Notifications
You must be signed in to change notification settings - Fork 731
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
fix: GraphQLEnum value camelCase conversion strategy #2745
Conversation
✅ Deploy Preview for apollo-ios-docs canceled.
|
I'm putting this back into draft to fix #2749. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for nailing this @calvincestari! Let's just make sure the license is okay and then move this forward!
Sources/ApolloCodegenLib/Templates/RenderingHelpers/GraphQLEnumValue+Rendered.swift
Outdated
Show resolved
Hide resolved
} | ||
return value | ||
|
||
return value.components(separatedBy: "_") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might look odd to be separating by _
and then converting empty elements back to _
but that's the trick to preserving leading/trailing _
without having to find the first/last indexes around them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
components(separatedBy:)
also preserves empty _
positions vs. split
which would just give us the inner 'words'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome job on this!
This PR refactors the
.camelCase
conversation strategy implementationUses the_convertFromSnakeCase
implementation fromJSONDecoder
inFoundation
with modifications. This question in the Swift forums makes me hopeful that one day we can remove this code and use a Swift standard library implementation, but we're not there yet.