From 47f2430e87790b6f6f98e4de98b23b6892ff8121 Mon Sep 17 00:00:00 2001 From: Craig Siemens Date: Mon, 18 May 2020 19:15:00 -0600 Subject: [PATCH] Updates for PR comments: - Renamed CustomScalarFormat.default to none since it isnt applying any formatting. - Added the passthroughCustomScalars flag when using passthroughWithPrefix to be safe. The CLI documentation doesnt mention that that flag is added when using customScalarsPrefix. --- Sources/ApolloCodegenLib/ApolloCodegenOptions.swift | 7 ++++--- Tests/ApolloCodegenTests/ApolloCodegenTests.swift | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Sources/ApolloCodegenLib/ApolloCodegenOptions.swift b/Sources/ApolloCodegenLib/ApolloCodegenOptions.swift index 74b60da772..3dc7233e79 100644 --- a/Sources/ApolloCodegenLib/ApolloCodegenOptions.swift +++ b/Sources/ApolloCodegenLib/ApolloCodegenOptions.swift @@ -55,7 +55,7 @@ public struct ApolloCodegenOptions { /// Enum to select how to handle properties using a custom scalar from the schema. public enum CustomScalarFormat: Equatable { /// Uses a default type instead of a custom scalar. - case `default` + case none /// Use your own types for custom scalars. case passthrough /// Use your own types for custom scalars with a prefix. @@ -102,7 +102,7 @@ public struct ApolloCodegenOptions { only: URL? = nil, operationIDsURL: URL? = nil, outputFormat: OutputFormat, - customScalarFormat: CustomScalarFormat = .default, + customScalarFormat: CustomScalarFormat = .none, suppressSwiftMultilineStringLiterals: Bool = false, urlToSchemaFile: URL, downloadTimeout: Double = 30.0) { @@ -180,11 +180,12 @@ public struct ApolloCodegenOptions { } switch customScalarFormat { - case .default: + case .none: break case .passthrough: arguments.append("--passthroughCustomScalars") case .passthroughWithPrefix(let prefix): + arguments.append("--passthroughCustomScalars") arguments.append("--customScalarsPrefix='\(prefix)'") } diff --git a/Tests/ApolloCodegenTests/ApolloCodegenTests.swift b/Tests/ApolloCodegenTests/ApolloCodegenTests.swift index 4d9382b12d..f71d7f3d7c 100644 --- a/Tests/ApolloCodegenTests/ApolloCodegenTests.swift +++ b/Tests/ApolloCodegenTests/ApolloCodegenTests.swift @@ -42,7 +42,7 @@ class ApolloCodegenTests: XCTestCase { XCTFail("Nope, this should be a single file!") } XCTAssertFalse(options.omitDeprecatedEnumCases) - XCTAssertEqual(options.customScalarFormat, .default) + XCTAssertEqual(options.customScalarFormat, .none) XCTAssertEqual(options.urlToSchemaFile, schema) XCTAssertEqual(options.modifier, .public) @@ -104,6 +104,7 @@ class ApolloCodegenTests: XCTestCase { "--only='\(only.path)'", "--operationIdsPath='\(operationIDsURL.path)'", "--omitDeprecatedEnumCases", + "--passthroughCustomScalars", "--customScalarsPrefix='\(prefix)'", "'\(output.path)'", ])