Skip to content

Commit

Permalink
Updates for PR comments:
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
CraigSiemens committed May 19, 2020
1 parent 4f3bbd5 commit 47f2430
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Sources/ApolloCodegenLib/ApolloCodegenOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)'")
}

Expand Down
3 changes: 2 additions & 1 deletion Tests/ApolloCodegenTests/ApolloCodegenTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -104,6 +104,7 @@ class ApolloCodegenTests: XCTestCase {
"--only='\(only.path)'",
"--operationIdsPath='\(operationIDsURL.path)'",
"--omitDeprecatedEnumCases",
"--passthroughCustomScalars",
"--customScalarsPrefix='\(prefix)'",
"'\(output.path)'",
])
Expand Down

0 comments on commit 47f2430

Please sign in to comment.