Couldn't build the generated graphql project when using some reserved words in the graphql file #2765
Labels
bug
Generally incorrect behavior
codegen
Issues related to or arising from code generation
planned-next
Slated to be included in the next release
Milestone
Summary
Hello there, Thank you for hard work in the new major version of apollo-ios
But I have an issue with the new code generation.
I couldn't build the generated graphql project that there are some reserved words in the graphql files because the variable name is one of the reserved words in swift language.
For example If I create a schema with the swift reserved words and use it in my .graphql file like this
Schema File
GraphQL File
After I run
./apollo-ios-cli generate
and build my xcode project there will be an error in my generated graphql project that shownKeyword 'for' cannot be used as an identifier here
.In
AnimalQuery.graphql.swift
You will see in the linepublic var for: String { __data["for"] }
that we couldn't usefor
as a variable name in swift. But forif
variable it works correctly because it is escaped by the code generation.AnimalQuery.graphql.swift
Version
v1.0.5
Steps to reproduce the behavior
Logs
Keyword 'for' cannot be used as an identifier here
Anything else?
I have looked into the reserved words list in the apollo-tooling project and the new one in apollo-ios. I found that list of the reserved words are not the same (there is no
for
keyword in the new code generation list too). I think if the reserved words list is the same, it should works correctly.Ref:
Reserved words in the apollo-tooling project
Reserved words in the apollo-ios project (v1.0.5)
The workaround for this problem if I use the alias name for the reserved word variable. it still works really fine.
For example: Aninal.graphql
The text was updated successfully, but these errors were encountered: