Skip to content
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

Syntax Error when generating Swift file where model contains reserved word #33

Closed
kreed-rmn opened this issue Dec 29, 2016 · 0 comments
Closed

Comments

@kreed-rmn
Copy link

If you have a query like:

query GetSimpleQuery {
    member {
        profile {
            private
        }
    }
}

This'll generate

public final class GetSimpleQueryQuery: GraphQLQuery {
  public static let operationDefinition =
    "query GetSimpleQuery {" +
    "  member {" +
    "    profile {" +
    "      private" +
    "    }" +
    "  }" +
    "}"
  public init() {
  }

  public struct Data: GraphQLMappable {
    public let member: Member?

    public init(reader: GraphQLResultReader) throws {
      member = try reader.optionalValue(for: Field(responseName: "member"))
    }

    public struct Member: GraphQLMappable {
      public let __typename = "Member"
      public let profile: Profile

      public init(reader: GraphQLResultReader) throws {
        profile = try reader.value(for: Field(responseName: "profile"))
      }

      public struct Profile: GraphQLMappable {
        public let __typename = "MemberProfile"
        public let private: Bool?

        public init(reader: GraphQLResultReader) throws {
          private = try reader.optionalValue(for: Field(responseName: "private"))
        }
      }
    }
  }
}

Which produces the error:

Keyword private cannot be used as an identifier here

When generating .swift files can we escape these?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant