diff --git a/src/swift/codeGeneration.ts b/src/swift/codeGeneration.ts index b9fd0d6..b408074 100644 --- a/src/swift/codeGeneration.ts +++ b/src/swift/codeGeneration.ts @@ -814,12 +814,6 @@ export class SwiftAPIGenerator extends SwiftGenerator { const properties = fields.map(this.helpers.propertyFromInputField, this.helpers); - properties.forEach(property => { - if (property.isOptional) { - property.typeName = `Optional<${property.typeName}>`; - } - }); - this.structDeclaration({ structName, description, adoptedProtocols }, () => { this.printOnNewline(`public var graphQLMap: GraphQLMap`); diff --git a/test/swift/__snapshots__/codeGeneration.ts.snap b/test/swift/__snapshots__/codeGeneration.ts.snap index b130a5e..fbb40e4 100644 --- a/test/swift/__snapshots__/codeGeneration.ts.snap +++ b/test/swift/__snapshots__/codeGeneration.ts.snap @@ -1466,7 +1466,7 @@ exports[`Swift code generation #typeDeclarationForGraphQLType() should generate public struct ReviewInput: GraphQLMapConvertible { public var graphQLMap: GraphQLMap - public init(stars: Int, commentary: Optional = nil, favoriteColor: Optional = nil) { + public init(stars: Int, commentary: String? = nil, favoriteColor: ColorInput? = nil) { graphQLMap = [\\"stars\\": stars, \\"commentary\\": commentary, \\"favorite_color\\": favoriteColor] } @@ -1481,9 +1481,9 @@ public struct ReviewInput: GraphQLMapConvertible { } /// Comment about the movie, optional - public var commentary: Optional { + public var commentary: String? { get { - return graphQLMap[\\"commentary\\"] as! Optional + return graphQLMap[\\"commentary\\"] as! String? } set { graphQLMap.updateValue(newValue, forKey: \\"commentary\\") @@ -1491,9 +1491,9 @@ public struct ReviewInput: GraphQLMapConvertible { } /// Favorite color, optional - public var favoriteColor: Optional { + public var favoriteColor: ColorInput? { get { - return graphQLMap[\\"favoriteColor\\"] as! Optional + return graphQLMap[\\"favoriteColor\\"] as! ColorInput? } set { graphQLMap.updateValue(newValue, forKey: \\"favoriteColor\\")