From 34c101c790b19f34b34e76c7acd501774121917c Mon Sep 17 00:00:00 2001
From: Calvin Cestari <calvin.cestari@apollographql.com>
Date: Thu, 10 Nov 2022 16:54:46 -0800
Subject: [PATCH 01/10] Changes operations output config default

---
 .../ApolloCodegenConfiguration.swift          |  2 +-
 Sources/CodegenCLI/Commands/Initialize.swift  |  2 +-
 .../ApolloCodegenConfigurationTests.swift     |  2 +-
 .../Templates/InputObjectTemplateTests.swift  | 50 +++++++++++--------
 4 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/Sources/ApolloCodegenLib/ApolloCodegenConfiguration.swift b/Sources/ApolloCodegenLib/ApolloCodegenConfiguration.swift
index cb36564b2a..8d13528b14 100644
--- a/Sources/ApolloCodegenLib/ApolloCodegenConfiguration.swift
+++ b/Sources/ApolloCodegenLib/ApolloCodegenConfiguration.swift
@@ -169,7 +169,7 @@ public struct ApolloCodegenConfiguration: Codable, Equatable {
 
     /// Default property values
     public struct Default {
-      public static let operations: OperationsFileOutput = .relative(subpath: nil)
+      public static let operations: OperationsFileOutput = .inSchemaModule
       public static let testMocks: TestMockFileOutput = .none
       public static let operationIdentifiersPath: String? = nil
     }
diff --git a/Sources/CodegenCLI/Commands/Initialize.swift b/Sources/CodegenCLI/Commands/Initialize.swift
index d7ab132ace..861423ed33 100644
--- a/Sources/CodegenCLI/Commands/Initialize.swift
+++ b/Sources/CodegenCLI/Commands/Initialize.swift
@@ -159,7 +159,7 @@ extension ApolloCodegenConfiguration {
           }
         },
         "operations" : {
-          "relative" : {
+          "inSchemaModule" : {
           }
         }
       }
diff --git a/Tests/ApolloCodegenTests/ApolloCodegenConfigurationTests.swift b/Tests/ApolloCodegenTests/ApolloCodegenConfigurationTests.swift
index fe46b4e2b5..e9478ed187 100644
--- a/Tests/ApolloCodegenTests/ApolloCodegenConfigurationTests.swift
+++ b/Tests/ApolloCodegenTests/ApolloCodegenConfigurationTests.swift
@@ -70,7 +70,7 @@ class ApolloCodegenConfigurationTests: XCTestCase {
 
     // then
     expect(output.operationIdentifiersPath).to(beNil())
-    expect(output.operations).to(equal(.relative(subpath: nil)))
+    expect(output.operations).to(equal(.inSchemaModule))
   }
 
   func test__initializer__givenMinimalApolloCodegenConfiguration_buildsCorrectDefaults() {
diff --git a/Tests/ApolloCodegenTests/CodeGeneration/Templates/InputObjectTemplateTests.swift b/Tests/ApolloCodegenTests/CodeGeneration/Templates/InputObjectTemplateTests.swift
index 965acc6831..18e835ecf8 100644
--- a/Tests/ApolloCodegenTests/CodeGeneration/Templates/InputObjectTemplateTests.swift
+++ b/Tests/ApolloCodegenTests/CodeGeneration/Templates/InputObjectTemplateTests.swift
@@ -261,12 +261,12 @@ class InputObjectTemplateTests: XCTestCase {
         intField: GraphQLNullable<Int> = nil,
         boolField: GraphQLNullable<Bool> = nil,
         floatField: GraphQLNullable<Double> = nil,
-        customScalarField: GraphQLNullable<TestSchema.CustomScalar> = nil,
-        lowercaseCustomScalarField: GraphQLNullable<TestSchema.LowercaseCustomScalar> = nil,
-        enumField: GraphQLNullable<GraphQLEnum<TestSchema.EnumType>> = nil,
-        lowercaseEnumField: GraphQLNullable<GraphQLEnum<TestSchema.LowercaseEnumType>> = nil,
-        inputField: GraphQLNullable<TestSchema.InnerInputObject> = nil,
-        lowercaseInputField: GraphQLNullable<TestSchema.LowercaseInnerInputObject> = nil,
+        customScalarField: GraphQLNullable<CustomScalar> = nil,
+        lowercaseCustomScalarField: GraphQLNullable<LowercaseCustomScalar> = nil,
+        enumField: GraphQLNullable<GraphQLEnum<EnumType>> = nil,
+        lowercaseEnumField: GraphQLNullable<GraphQLEnum<LowercaseEnumType>> = nil,
+        inputField: GraphQLNullable<InnerInputObject> = nil,
+        lowercaseInputField: GraphQLNullable<LowercaseInnerInputObject> = nil,
         listField: GraphQLNullable<[String?]> = nil
       ) {
         __data = InputDict([
@@ -304,32 +304,32 @@ class InputObjectTemplateTests: XCTestCase {
         set { __data["floatField"] = newValue }
       }
 
-      public var customScalarField: GraphQLNullable<TestSchema.CustomScalar> {
+      public var customScalarField: GraphQLNullable<CustomScalar> {
         get { __data["customScalarField"] }
         set { __data["customScalarField"] = newValue }
       }
 
-      public var lowercaseCustomScalarField: GraphQLNullable<TestSchema.LowercaseCustomScalar> {
+      public var lowercaseCustomScalarField: GraphQLNullable<LowercaseCustomScalar> {
         get { __data["lowercaseCustomScalarField"] }
         set { __data["lowercaseCustomScalarField"] = newValue }
       }
 
-      public var enumField: GraphQLNullable<GraphQLEnum<TestSchema.EnumType>> {
+      public var enumField: GraphQLNullable<GraphQLEnum<EnumType>> {
         get { __data["enumField"] }
         set { __data["enumField"] = newValue }
       }
 
-      public var lowercaseEnumField: GraphQLNullable<GraphQLEnum<TestSchema.LowercaseEnumType>> {
+      public var lowercaseEnumField: GraphQLNullable<GraphQLEnum<LowercaseEnumType>> {
         get { __data["lowercaseEnumField"] }
         set { __data["lowercaseEnumField"] = newValue }
       }
 
-      public var inputField: GraphQLNullable<TestSchema.InnerInputObject> {
+      public var inputField: GraphQLNullable<InnerInputObject> {
         get { __data["inputField"] }
         set { __data["inputField"] = newValue }
       }
 
-      public var lowercaseInputField: GraphQLNullable<TestSchema.LowercaseInnerInputObject> {
+      public var lowercaseInputField: GraphQLNullable<LowercaseInnerInputObject> {
         get { __data["lowercaseInputField"] }
         set { __data["lowercaseInputField"] = newValue }
       }
@@ -749,21 +749,22 @@ class InputObjectTemplateTests: XCTestCase {
   func test__render__given_NullableListOfNullableEnum_NoDefault__generates_NullableParameter_OptionalItem_InitializerNilDefault() throws {
     // given
     buildSubject(fields: [
-      GraphQLInputField.mock("nullableListNullableItem",
-                             type: .list(.enum(.mock(name: "EnumValue"))),
-                             defaultValue: nil)
+      GraphQLInputField.mock(
+        "nullableListNullableItem",
+        type: .list(.enum(.mock(name: "EnumValue"))),
+        defaultValue: nil)
     ])
 
     let expected = """
       public init(
-        nullableListNullableItem: GraphQLNullable<[GraphQLEnum<TestSchema.EnumValue>?]> = nil
+        nullableListNullableItem: GraphQLNullable<[GraphQLEnum<EnumValue>?]> = nil
       ) {
         __data = InputDict([
           "nullableListNullableItem": nullableListNullableItem
         ])
       }
 
-      public var nullableListNullableItem: GraphQLNullable<[GraphQLEnum<TestSchema.EnumValue>?]> {
+      public var nullableListNullableItem: GraphQLNullable<[GraphQLEnum<EnumValue>?]> {
     """
 
     // when
@@ -2042,7 +2043,10 @@ class InputObjectTemplateTests: XCTestCase {
         "nullableListNullableItem",
         type: .list(.enum(.mock(name: "EnumValue"))),
         defaultValue: nil)],
-      config: .mock(schemaName: "testschema")
+      config: .mock(
+        schemaName: "testschema",
+        output: .mock(operations: .relative(subpath: nil))
+      )
     )
 
     let expected = """
@@ -2071,7 +2075,10 @@ class InputObjectTemplateTests: XCTestCase {
         "nullableListNullableItem",
         type: .list(.enum(.mock(name: "EnumValue"))),
         defaultValue: nil)],
-      config: .mock(schemaName: "TESTSCHEMA")
+      config: .mock(
+        schemaName: "TESTSCHEMA",
+        output: .mock(operations: .relative(subpath: nil))
+      )
     )
 
     let expected = """
@@ -2100,7 +2107,10 @@ class InputObjectTemplateTests: XCTestCase {
         "nullableListNullableItem",
         type: .list(.enum(.mock(name: "EnumValue"))),
         defaultValue: nil)],
-      config: .mock(schemaName: "TestSchema")
+      config: .mock(
+        schemaName: "TestSchema",
+        output: .mock(operations: .relative(subpath: nil))
+      )
     )
 
     let expected = """

From 4525c8e781846c3ea01960495634509ab5cf003e Mon Sep 17 00:00:00 2001
From: Calvin Cestari <calvin.cestari@apollographql.com>
Date: Mon, 14 Nov 2022 10:56:46 -0800
Subject: [PATCH 02/10] Bumps swift-argument-parser dependency to minimum 1.2.0

---
 Apollo.xcodeproj/project.pbxproj                              | 4 ++--
 .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 4 ++--
 Package.resolved                                              | 4 ++--
 Package.swift                                                 | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/Apollo.xcodeproj/project.pbxproj b/Apollo.xcodeproj/project.pbxproj
index 9f8c482c65..ec84d188df 100644
--- a/Apollo.xcodeproj/project.pbxproj
+++ b/Apollo.xcodeproj/project.pbxproj
@@ -6627,8 +6627,8 @@
 			isa = XCRemoteSwiftPackageReference;
 			repositoryURL = "https://github.com/apple/swift-argument-parser.git";
 			requirement = {
-				kind = upToNextMinorVersion;
-				minimumVersion = 1.1.3;
+				kind = upToNextMajorVersion;
+				minimumVersion = 1.2.0;
 			};
 		};
 		E6E4209026A7DF4200B82624 /* XCRemoteSwiftPackageReference "InflectorKit" */ = {
diff --git a/Apollo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Apollo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
index dacc3e70b1..c6dc8f759a 100644
--- a/Apollo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
+++ b/Apollo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
@@ -50,8 +50,8 @@
       "kind" : "remoteSourceControl",
       "location" : "https://github.com/apple/swift-argument-parser.git",
       "state" : {
-        "revision" : "df9ee6676cd5b3bf5b330ec7568a5644f547201b",
-        "version" : "1.1.3"
+        "revision" : "fddd1c00396eed152c45a46bea9f47b98e59301d",
+        "version" : "1.2.0"
       }
     },
     {
diff --git a/Package.resolved b/Package.resolved
index 34b8aaab7a..a670c9ac98 100644
--- a/Package.resolved
+++ b/Package.resolved
@@ -23,8 +23,8 @@
       "kind" : "remoteSourceControl",
       "location" : "https://github.com/apple/swift-argument-parser.git",
       "state" : {
-        "revision" : "df9ee6676cd5b3bf5b330ec7568a5644f547201b",
-        "version" : "1.1.3"
+        "revision" : "fddd1c00396eed152c45a46bea9f47b98e59301d",
+        "version" : "1.2.0"
       }
     },
     {
diff --git a/Package.swift b/Package.swift
index 6d9c331bda..b429edf0d6 100644
--- a/Package.swift
+++ b/Package.swift
@@ -33,7 +33,7 @@ let package = Package(
       .upToNextMajor(from: "1.0.0")),
     .package(
       url: "https://github.com/apple/swift-argument-parser.git", 
-      .upToNextMajor(from: "1.1.2")),
+      .upToNextMajor(from: "1.2.0")),
   ],
   targets: [
     .target(

From 12b377409de4454b34ffbeb10f8970e308eb25dc Mon Sep 17 00:00:00 2001
From: Calvin Cestari <calvin.cestari@apollographql.com>
Date: Tue, 15 Nov 2022 21:52:45 -0800
Subject: [PATCH 03/10] Adds --module-type and --target-name to init required
 parameters

---
 .../ApolloCodegenConfiguration.swift          |   3 +-
 Sources/CodegenCLI/Commands/Initialize.swift  |  94 ++++++-
 .../Commands/InitializeTests.swift            | 250 ++++++++++++++----
 3 files changed, 282 insertions(+), 65 deletions(-)

diff --git a/Sources/ApolloCodegenLib/ApolloCodegenConfiguration.swift b/Sources/ApolloCodegenLib/ApolloCodegenConfiguration.swift
index 8d13528b14..f4ce0b3bd9 100644
--- a/Sources/ApolloCodegenLib/ApolloCodegenConfiguration.swift
+++ b/Sources/ApolloCodegenLib/ApolloCodegenConfiguration.swift
@@ -226,8 +226,7 @@ public struct ApolloCodegenConfiguration: Codable, Equatable {
   public struct SchemaTypesFileOutput: Codable, Equatable {
     /// Local path where the generated schema types files should be stored.
     public let path: String
-    /// Automation to ease the integration of the generated schema types file with compatible
-    /// dependency managers.
+    /// How to package the schema types for dependency management.
     public let moduleType: ModuleType
 
     /// Designated initializer.
diff --git a/Sources/CodegenCLI/Commands/Initialize.swift b/Sources/CodegenCLI/Commands/Initialize.swift
index 861423ed33..a408d6815d 100644
--- a/Sources/CodegenCLI/Commands/Initialize.swift
+++ b/Sources/CodegenCLI/Commands/Initialize.swift
@@ -15,7 +15,26 @@ public struct Initialize: ParsableCommand {
     name: [.long, .customShort("n")],
     help: "Name used to scope the generated schema type files."
   )
-  var schemaName: String = ""
+  var schemaName: String
+
+  @Option(
+    name: [.long, .customShort("m")],
+    help: """
+      How to package the schema types for dependency management. Possible types: \
+      \(ModuleTypeExpressibleByArgument.allValueStrings.joined(separator: ", ")).
+      """
+  )
+  var moduleType: ModuleTypeExpressibleByArgument
+
+  @Option(
+    name: [.long, .customShort("t")],
+    help: """
+      Name of the target in which the schema types files will be manually embedded. This is \
+      required for the \"embeddedInTarget\" module type and will be ignored for all other module \
+      types.
+      """
+  )
+  var targetName: String? = nil
 
   @Option(
     name: .shortAndLong,
@@ -45,8 +64,21 @@ public struct Initialize: ParsableCommand {
   public init() { }
 
   public func validate() throws {
-    guard !schemaName.isEmpty else {
-      throw ValidationError("Schema name is missing, use the --schema-name option to specify.")
+    guard !schemaName.trimmingCharacters(in: .whitespaces).isEmpty else {
+      throw ValidationError("--schema-name value cannot be empty.")
+    }
+
+    let targetNameValiationError = ValidationError("""
+      Target name is required when using \"embeddedInTarget\" module type. Use --target-name \
+      to specify.
+      """
+    )
+
+    switch (moduleType, targetName?.isEmpty) {
+    case (.embeddedInTarget, nil), (.embeddedInTarget, true):
+      throw targetNameValiationError
+    default:
+      break;
     }
   }
 
@@ -56,8 +88,11 @@ public struct Initialize: ParsableCommand {
 
   func _run(fileManager: ApolloFileManager = .default, output: OutputClosure? = nil) throws {
     let encoded = try ApolloCodegenConfiguration
-      .minimalJSON(schemaName: schemaName)
-      .asData()
+      .minimalJSON(
+        schemaName: schemaName,
+        moduleType: moduleType.rawValue,
+        targetName: targetName
+      ).asData()
 
     if print {
       try print(data: encoded, output: output)
@@ -119,15 +154,34 @@ public struct Initialize: ParsableCommand {
 // MARK: - Internal extensions
 
 extension ApolloCodegenConfiguration {
-  static func minimalJSON(schemaName: String) -> String {
+  static func minimalJSON(
+    schemaName: String,
+    moduleType: String,
+    targetName: String?
+  ) -> String {
     #if COCOAPODS
-      minimalJSON(schemaName: schemaName, supportCocoaPods: true)
+      minimalJSON(
+        schemaName: schemaName,
+        supportCocoaPods: true,
+        moduleType: moduleType,
+        targetName: targetName
+      )
     #else
-      minimalJSON(schemaName: schemaName, supportCocoaPods: false)
+      minimalJSON(
+        schemaName: schemaName,
+        supportCocoaPods: false,
+        moduleType: moduleType,
+        targetName: targetName
+      )
     #endif
   }
 
-  static func minimalJSON(schemaName: String, supportCocoaPods: Bool) -> String {
+  static func minimalJSON(
+    schemaName: String,
+    supportCocoaPods: Bool,
+    moduleType: String,
+    targetName: String?
+  ) -> String {
     let cocoaPodsOption = supportCocoaPods ? """
 
         "options" : {
@@ -135,6 +189,15 @@ extension ApolloCodegenConfiguration {
         },
       """ : ""
 
+    let moduleTarget: String = {
+      guard let targetName = targetName else { return "}" }
+
+      return """
+          "name" : "\(targetName)"
+                }
+        """
+    }()
+
     return """
     {
       "schemaName" : "\(schemaName)",\(cocoaPodsOption)
@@ -154,8 +217,8 @@ extension ApolloCodegenConfiguration {
         "schemaTypes" : {
           "path" : "./\(schemaName)",
           "moduleType" : {
-            \(supportCocoaPods ? "\"other\"" : "\"swiftPackageManager\"") : {
-            }
+            "\(moduleType)" : {
+            \(moduleTarget)
           }
         },
         "operations" : {
@@ -167,3 +230,12 @@ extension ApolloCodegenConfiguration {
     """
   }
 }
+
+/// A custom enum that matches ApolloCodegenConfiguration.SchemaTypesFileOutput.ModuleType, but
+/// specifically without associated values so that it can conform to ExpressibleByArgument and be
+/// parsed from the command line.
+enum ModuleTypeExpressibleByArgument: String, ExpressibleByArgument, CaseIterable {
+  case embeddedInTarget
+  case swiftPackageManager
+  case other
+}
diff --git a/Tests/CodegenCLITests/Commands/InitializeTests.swift b/Tests/CodegenCLITests/Commands/InitializeTests.swift
index 2d841f41e0..110021ea19 100644
--- a/Tests/CodegenCLITests/Commands/InitializeTests.swift
+++ b/Tests/CodegenCLITests/Commands/InitializeTests.swift
@@ -7,7 +7,10 @@ import ApolloCodegenLib
 class InitializeTests: XCTestCase {
 
   var mockFileManager: MockApolloFileManager!
-  let baseOptions = ["--schema-name=MockSchema"]
+  let requiredOptions = [
+    "--schema-name=MockSchema",
+    "--module-type=swiftPackageManager",
+  ]
 
   override func setUp() {
     super.setUp()
@@ -30,14 +33,32 @@ class InitializeTests: XCTestCase {
   // MARK: - Parsing Tests
 
   func test__parsing__givenParameters_none_shouldThrow() throws {
-    expect { try self.parse([]) }.to(throwUserValidationError(
-      ValidationError("Schema name is missing, use the --schema-name option to specify.")
-    ))
+    expect { try self.parse([]) }.to(throwError())
+  }
+
+  func test__parsing__givenParameters_missingSchemaName_shouldThrow() throws {
+    // given
+    let options = [
+      "--module-type=swiftPackageManager",
+    ]
+
+    // when
+    expect { try self.parse(options) }.to(throwError())
+  }
+
+  func test__parsing__givenParameters_missingModuleType_shouldThrow() throws {
+    // given
+    let options = [
+      "--schema-name=MySchemaName",
+    ]
+
+    // when
+    expect { try self.parse(options) }.to(throwError())
   }
 
   func test__parsing__givenParameters_required_shouldUseDefaults() throws {
     // when
-    let command = try parse(baseOptions)
+    let command = try parse(requiredOptions)
 
     // then
     expect(command.path).to(equal(Constants.defaultFilePath))
@@ -48,7 +69,8 @@ class InitializeTests: XCTestCase {
   func test__parsing__givenParameters_schemaNameLongformat_shouldParse() throws {
     // given
     let options = [
-      "--schema-name=LongFormatSchemaName"
+      "--schema-name=LongFormatSchemaName",
+      "--module-type=swiftPackageManager",
     ]
 
     // when
@@ -61,7 +83,8 @@ class InitializeTests: XCTestCase {
   func test__parsing__givenParameters_schemaNameShortFormat_shouldParse() throws {
     // given
     let options = [
-      "-n=ShortFormatSchemaName"
+      "-n=ShortFormatSchemaName",
+      "--module-type=swiftPackageManager",
     ]
 
     // when
@@ -71,11 +94,69 @@ class InitializeTests: XCTestCase {
     expect(command.schemaName).to(equal("ShortFormatSchemaName"))
   }
 
+  func test__parsing__givenParameters_moduleNameLongFormat_shouldParse() throws {
+    // given
+    let options = [
+      "--schema-name=MySchemaName",
+      "--module-type=swiftPackageManager",
+    ]
+
+    // when
+    let command = try parse(options)
+
+    // then
+    expect(command.moduleType).to(equal(.swiftPackageManager))
+  }
+
+  func test__parsing__givenParameters_moduleNameShortFormat_shouldParse() throws {
+    // given
+    let options = [
+      "--schema-name=MySchemaName",
+      "-m=swiftPackageManager",
+    ]
+
+    // when
+    let command = try parse(options)
+
+    // then
+    expect(command.moduleType).to(equal(.swiftPackageManager))
+  }
+
+  func test__parsing__givenParameters_targetNameLongFormat_shouldParse() throws {
+    // given
+    let options = [
+      "--schema-name=MySchemaName",
+      "--module-type=embeddedInTarget",
+      "--target-name=LongFormatTargetName",
+    ]
+
+    // when
+    let command = try parse(options)
+
+    // then
+    expect(command.targetName).to(equal("LongFormatTargetName"))
+  }
+
+  func test__parsing__givenParameters_targetNameShortFormat_shouldParse() throws {
+    // given
+    let options = [
+      "--schema-name=MySchemaName",
+      "--module-type=embeddedInTarget",
+      "-t=ShortFormatTargetName",
+    ]
+
+    // when
+    let command = try parse(options)
+
+    // then
+    expect(command.targetName).to(equal("ShortFormatTargetName"))
+  }
+
   func test__parsing__givenParameters_pathLongFormat_shouldParse() throws {
     // given
     let path = "./configuration.json"
 
-    let options = baseOptions + [
+    let options = requiredOptions + [
       "--path=\(path)"
     ]
 
@@ -90,7 +171,7 @@ class InitializeTests: XCTestCase {
     // given
     let path = "./configuration.json"
 
-    let options = baseOptions + [
+    let options = requiredOptions + [
       "-p=\(path)"
     ]
 
@@ -103,7 +184,7 @@ class InitializeTests: XCTestCase {
 
   func test__parsing__givenParameters_overwriteLongFormat_shouldParse() throws {
     // given
-    let options = baseOptions + [
+    let options = requiredOptions + [
       "--overwrite"
     ]
 
@@ -116,7 +197,7 @@ class InitializeTests: XCTestCase {
 
   func test__parsing__givenParameters_overwriteShortFormat_shouldParse() throws {
     // given
-    let options = baseOptions + [
+    let options = requiredOptions + [
       "-w"
     ]
 
@@ -129,7 +210,7 @@ class InitializeTests: XCTestCase {
 
   func test__parsing__givenParameters_printLongFormat_shouldParse() throws {
     // given
-    let options = baseOptions + [
+    let options = requiredOptions + [
       "--print"
     ]
 
@@ -142,7 +223,7 @@ class InitializeTests: XCTestCase {
 
   func test__parsing__givenParameters_printShortFormat_shouldParse() throws {
     // given
-    let options = baseOptions + [
+    let options = requiredOptions + [
       "-s"
     ]
 
@@ -155,7 +236,7 @@ class InitializeTests: XCTestCase {
 
   func test__parsing__givenParameters_unknown_shouldThrow() throws {
     // given
-    let options = baseOptions + [
+    let options = requiredOptions + [
       "--unknown"
     ]
 
@@ -164,14 +245,80 @@ class InitializeTests: XCTestCase {
       .to(throwUnknownOptionError())
   }
 
+  // MARK: - Validation Tests
+
+  func test__validation__givenWhitespaceSchemaName_shouldThrowValidationError() throws {
+    // given
+    let options = [
+      "--schema-name= ",
+      "--module-type=swiftPackageManager",
+    ]
+
+    // then
+    expect { try self.parse(options) }.to(throwUserValidationError(
+      ValidationError("--schema-name value cannot be empty.")
+    ))
+  }
+
+  func test__validation__givenModuleType_embeddedInTarget_withNoTargetName_shouldThrowValidationError() throws {
+    // given
+    let options = [
+      "--schema-name=MySchemaName",
+      "--module-type=embeddedInTarget",
+    ]
+
+    // then
+    expect { try self.parse(options) }.to(throwUserValidationError(
+      ValidationError("""
+        Target name is required when using \"embeddedInTarget\" module type. Use --target-name \
+        to specify.
+        """
+      )
+    ))
+  }
+
+  func test__validation__givenModuleType_embeddedInTarget_withTargetName_shouldNotThrow() throws {
+    // given
+    let options = [
+      "--schema-name=MySchemaName",
+      "--module-type=embeddedInTarget",
+      "--target-name=MyTarget",
+    ]
+
+    // then
+    expect { try self.parse(options) }.notTo(throwError())
+  }
+
+  func test__validation__givenModuleType_swiftPackageManager_withNoTargetName_shouldNotThrow() throws {
+    // given
+    let options = [
+      "--schema-name=MySchemaName",
+      "--module-type=swiftPackageManager",
+    ]
+
+    // then
+    expect { try self.parse(options) }.notTo(throwError())
+  }
+
+  func test__validation__givenModuleType_other_withNoTargetName_shouldNotThrow() throws {
+    // given
+    let options = [
+      "--schema-name=MySchemaName",
+      "--module-type=other",
+    ]
+
+    // then
+    expect { try self.parse(options) }.notTo(throwError())
+  }
+
   // MARK: - Output Tests
 
   func test__output__givenParameters_pathCustom_overwriteDefault_whenNoExistingFile_shouldWriteToPath() throws {
     // given
     let outputPath = "./path/to/output.file"
 
-    let options = baseOptions + [
-      "--path=\(outputPath)"
+    let options = requiredOptions + [
+      "--path=\(outputPath)",
     ]
 
     let subject = try parse(options)
@@ -191,7 +338,12 @@ class InitializeTests: XCTestCase {
 
       expect(actualPath).to(equal(expectedPath))
       expect(data?.asString).to(equal(
-        ApolloCodegenConfiguration.minimalJSON(schemaName: "MockSchema")))
+        ApolloCodegenConfiguration.minimalJSON(
+          schemaName: "MockSchema",
+          moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager.rawValue,
+          targetName: nil
+        )
+      ))
 
       return true
     }))
@@ -206,7 +358,7 @@ class InitializeTests: XCTestCase {
     // given
     let outputPath = "./path/to/output.file"
 
-    let options = baseOptions + [
+    let options = requiredOptions + [
       "--path=\(outputPath)"
     ]
 
@@ -234,7 +386,7 @@ class InitializeTests: XCTestCase {
     // given
     let outputPath = "./path/to/output.file"
 
-    let options = baseOptions + [
+    let options = requiredOptions + [
       "--path=\(outputPath)",
       "--overwrite"
     ]
@@ -256,7 +408,11 @@ class InitializeTests: XCTestCase {
 
       expect(actualPath).to(equal(expectedPath))
       expect(data?.asString).to(equal(
-        ApolloCodegenConfiguration.minimalJSON(schemaName: "MockSchema")
+        ApolloCodegenConfiguration.minimalJSON(
+          schemaName: "MockSchema",
+          moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager.rawValue,
+          targetName: nil
+        )
       ))
 
       return true
@@ -270,7 +426,7 @@ class InitializeTests: XCTestCase {
 
   func test__output__givenParameters_printTrue_shouldPrintToStandardOutput() throws {
     // given
-    let options = baseOptions + [
+    let options = requiredOptions + [
       "--print"
     ]
 
@@ -284,12 +440,18 @@ class InitializeTests: XCTestCase {
 
     // then
     expect(output).toEventuallyNot(beNil())
-    expect(output).to(equal(ApolloCodegenConfiguration.minimalJSON(schemaName: "MockSchema")))
+    expect(output).to(equal(
+      ApolloCodegenConfiguration.minimalJSON(
+        schemaName: "MockSchema",
+        moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager.rawValue,
+        targetName: nil
+      )
+    ))
   }
 
   func test__output__givenParameters_bothPathAndPrint_shouldPrintToStandardOutput() throws {
     // given
-    let options = baseOptions + [
+    let options = requiredOptions + [
       "--path=./path/to/file",
       "--print"
     ]
@@ -304,7 +466,13 @@ class InitializeTests: XCTestCase {
 
     // then
     expect(output).toEventuallyNot(beNil())
-    expect(output).to(equal(ApolloCodegenConfiguration.minimalJSON(schemaName: "MockSchema")))
+    expect(output).to(equal(
+      ApolloCodegenConfiguration.minimalJSON(
+        schemaName: "MockSchema",
+        moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager.rawValue,
+        targetName: nil
+      )
+    ))
   }
 
   // MARK: - minimalJSON Tests
@@ -313,7 +481,9 @@ class InitializeTests: XCTestCase {
     // given
     let encoded = try ApolloCodegenConfiguration.minimalJSON(
       schemaName: "MockSchema",
-      supportCocoaPods: false
+      supportCocoaPods: false,
+      moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager.rawValue,
+      targetName: nil
     ).asData()
 
     // then
@@ -323,24 +493,13 @@ class InitializeTests: XCTestCase {
     expect(decoded.unsafelyUnwrapped.options.cocoapodsCompatibleImportStatements).to(beFalse())
   }
 
-  func test__decoding__givenMinimalJSON_cocoapodsIncompatible_shouldUseCorrectDefaults() throws {
-    // given
-    let encoded = try ApolloCodegenConfiguration.minimalJSON(
-      schemaName: "MockSchema",
-      supportCocoaPods: false
-    ).asData()
-
-    // then
-    let decoded = try JSONDecoder().decode(ApolloCodegenConfiguration.self, from: encoded)
-
-    expect(decoded.output.schemaTypes.moduleType).to(equal(.swiftPackageManager))
-  }
-
   func test__decoding__givenMinimalJSON_cocoapodsCompatible_shouldNotThrow() throws {
     // given
     let encoded = try ApolloCodegenConfiguration.minimalJSON(
       schemaName: "MockSchema",
-      supportCocoaPods: true
+      supportCocoaPods: true,
+      moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager.rawValue,
+      targetName: nil
     ).asData()
 
     // then
@@ -349,19 +508,6 @@ class InitializeTests: XCTestCase {
       .notTo(throwError())
     expect(decoded.unsafelyUnwrapped.options.cocoapodsCompatibleImportStatements).to(beTrue())
   }
-
-  func test__decoding__givenMinimalJSON_cocoapodsCompatible_shouldUseCorrectDefaults() throws {
-    // given
-    let encoded = try ApolloCodegenConfiguration.minimalJSON(
-      schemaName: "MockSchema",
-      supportCocoaPods: true
-    ).asData()
-
-    // then
-    let decoded = try JSONDecoder().decode(ApolloCodegenConfiguration.self, from: encoded)
-
-    expect(decoded.output.schemaTypes.moduleType).to(equal(.other))
-  }
 }
 
 extension Data {

From 3bc12aa50b648126d47156ee5ec7faafedf2679f Mon Sep 17 00:00:00 2001
From: Calvin Cestari <calvin.cestari@apollographql.com>
Date: Wed, 16 Nov 2022 14:05:25 -0800
Subject: [PATCH 04/10] Adds tests to ensure enum compatibility

---
 Sources/CodegenCLI/Commands/Initialize.swift  |  6 +-
 .../Commands/InitializeTests.swift            | 60 +++++++++++++++++--
 2 files changed, 57 insertions(+), 9 deletions(-)

diff --git a/Sources/CodegenCLI/Commands/Initialize.swift b/Sources/CodegenCLI/Commands/Initialize.swift
index a408d6815d..adc5e2c2c6 100644
--- a/Sources/CodegenCLI/Commands/Initialize.swift
+++ b/Sources/CodegenCLI/Commands/Initialize.swift
@@ -90,7 +90,7 @@ public struct Initialize: ParsableCommand {
     let encoded = try ApolloCodegenConfiguration
       .minimalJSON(
         schemaName: schemaName,
-        moduleType: moduleType.rawValue,
+        moduleType: moduleType,
         targetName: targetName
       ).asData()
 
@@ -156,7 +156,7 @@ public struct Initialize: ParsableCommand {
 extension ApolloCodegenConfiguration {
   static func minimalJSON(
     schemaName: String,
-    moduleType: String,
+    moduleType: ModuleTypeExpressibleByArgument,
     targetName: String?
   ) -> String {
     #if COCOAPODS
@@ -179,7 +179,7 @@ extension ApolloCodegenConfiguration {
   static func minimalJSON(
     schemaName: String,
     supportCocoaPods: Bool,
-    moduleType: String,
+    moduleType: ModuleTypeExpressibleByArgument,
     targetName: String?
   ) -> String {
     let cocoaPodsOption = supportCocoaPods ? """
diff --git a/Tests/CodegenCLITests/Commands/InitializeTests.swift b/Tests/CodegenCLITests/Commands/InitializeTests.swift
index 110021ea19..a51bb5005e 100644
--- a/Tests/CodegenCLITests/Commands/InitializeTests.swift
+++ b/Tests/CodegenCLITests/Commands/InitializeTests.swift
@@ -340,7 +340,7 @@ class InitializeTests: XCTestCase {
       expect(data?.asString).to(equal(
         ApolloCodegenConfiguration.minimalJSON(
           schemaName: "MockSchema",
-          moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager.rawValue,
+          moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager,
           targetName: nil
         )
       ))
@@ -410,7 +410,7 @@ class InitializeTests: XCTestCase {
       expect(data?.asString).to(equal(
         ApolloCodegenConfiguration.minimalJSON(
           schemaName: "MockSchema",
-          moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager.rawValue,
+          moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager,
           targetName: nil
         )
       ))
@@ -443,7 +443,7 @@ class InitializeTests: XCTestCase {
     expect(output).to(equal(
       ApolloCodegenConfiguration.minimalJSON(
         schemaName: "MockSchema",
-        moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager.rawValue,
+        moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager,
         targetName: nil
       )
     ))
@@ -469,12 +469,60 @@ class InitializeTests: XCTestCase {
     expect(output).to(equal(
       ApolloCodegenConfiguration.minimalJSON(
         schemaName: "MockSchema",
-        moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager.rawValue,
+        moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager,
         targetName: nil
       )
     ))
   }
 
+  // MARK: - ModuleType Conversion Tests
+
+  func test__moduleType__givenModuleTypeExpressibleByArgument_embeddedInTarget_shouldEqualSchemaTypesFileOutputModuleType_embeddedInTarget() throws {
+    // given
+    let encoded = try ApolloCodegenConfiguration.minimalJSON(
+      schemaName: "MockSchema",
+      supportCocoaPods: false,
+      moduleType: ModuleTypeExpressibleByArgument.embeddedInTarget,
+      targetName: "MyTarget"
+    ).asData()
+
+    // then
+    let decoded = try JSONDecoder().decode(ApolloCodegenConfiguration.self, from: encoded)
+
+    expect(decoded.output.schemaTypes.moduleType)
+      .to(equal(.embeddedInTarget(name: "MyTarget")))
+  }
+
+  func test__moduleType__givenModuleTypeExpressibleByArgument_swiftPackageManager_shouldEqualSchemaTypesFileOutputModuleType_swiftPackageManager() throws {
+    // given
+    let encoded = try ApolloCodegenConfiguration.minimalJSON(
+      schemaName: "MockSchema",
+      supportCocoaPods: false,
+      moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager,
+      targetName: nil
+    ).asData()
+
+    // then
+    let decoded = try JSONDecoder().decode(ApolloCodegenConfiguration.self, from: encoded)
+
+    expect(decoded.output.schemaTypes.moduleType).to(equal(.swiftPackageManager))
+  }
+
+  func test__moduleType__givenModuleTypeExpressibleByArgument_other_shouldEqualSchemaTypesFileOutputModuleType_other() throws {
+    // given
+    let encoded = try ApolloCodegenConfiguration.minimalJSON(
+      schemaName: "MockSchema",
+      supportCocoaPods: false,
+      moduleType: ModuleTypeExpressibleByArgument.other,
+      targetName: nil
+    ).asData()
+
+    // then
+    let decoded = try JSONDecoder().decode(ApolloCodegenConfiguration.self, from: encoded)
+
+    expect(decoded.output.schemaTypes.moduleType).to(equal(.other))
+  }
+
   // MARK: - minimalJSON Tests
 
   func test__decoding__givenMinimalJSON_cocoapodsIncompatible_shouldNotThrow() throws {
@@ -482,7 +530,7 @@ class InitializeTests: XCTestCase {
     let encoded = try ApolloCodegenConfiguration.minimalJSON(
       schemaName: "MockSchema",
       supportCocoaPods: false,
-      moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager.rawValue,
+      moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager,
       targetName: nil
     ).asData()
 
@@ -498,7 +546,7 @@ class InitializeTests: XCTestCase {
     let encoded = try ApolloCodegenConfiguration.minimalJSON(
       schemaName: "MockSchema",
       supportCocoaPods: true,
-      moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager.rawValue,
+      moduleType: ModuleTypeExpressibleByArgument.swiftPackageManager,
       targetName: nil
     ).asData()
 

From aa3f75716e2d5bc458586927dae4e6585f87d775 Mon Sep 17 00:00:00 2001
From: Calvin Cestari <calvin.cestari@apollographql.com>
Date: Wed, 16 Nov 2022 14:27:13 -0800
Subject: [PATCH 05/10] Fix CLI integration test

---
 .circleci/config.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.circleci/config.yml b/.circleci/config.yml
index ea2b8a8bee..c738b0d452 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -98,7 +98,7 @@ commands:
           name: CocoaPods - Install
       - run:
           working_directory: Tests/CodegenCLITests/pod-install-test/
-          command: ./Pods/Apollo/apollo-ios-cli init --schema-name NewTestSchema
+          command: ./Pods/Apollo/apollo-ios-cli init --schema-name NewTestSchema --module-type other
           name: CocoaPods - CLI Test (init)
       - run:
           working_directory: Tests/CodegenCLITests/pod-install-test/

From ffba679f19877d5247b2a791ee20b84e9d32725c Mon Sep 17 00:00:00 2001
From: Calvin Cestari <calvin.cestari@apollographql.com>
Date: Wed, 16 Nov 2022 14:27:56 -0800
Subject: [PATCH 06/10] Updates documentation

---
 docs/shared/pods-setup-codegen-panel.mdx         | 7 ++++---
 docs/shared/spm-setup-codegen-panel.mdx          | 5 +++--
 docs/source/code-generation/codegen-cli.mdx      | 6 ++++--
 docs/source/tutorial/codegen-getting-started.mdx | 6 +++---
 4 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/docs/shared/pods-setup-codegen-panel.mdx b/docs/shared/pods-setup-codegen-panel.mdx
index e583f12edf..44e718bb98 100644
--- a/docs/shared/pods-setup-codegen-panel.mdx
+++ b/docs/shared/pods-setup-codegen-panel.mdx
@@ -12,10 +12,11 @@ The Codegen CLI is located in your project at `Pods/Apollo/apollo-ios-cli`
 The Codegen CLI uses a JSON file to configure the code generation engine. Use the Codegen CLI `init` command to create this file with default values. From the directory of your `Podfile`, run:
 
 ```bash
-./Pods/Apollo/apollo-ios-cli init --schema-name ${MySchemaName}
+./Pods/Apollo/apollo-ios-cli init --schema-name ${MySchemaName} --module-type other
 ```
 
-`${MySchemaName}` should be the name you want for the namespace of your generated schema files.
+* `${MySchemaName}` should be the name you want for the namespace of your generated schema files.
+* `other` is the module type to use when your dependency manager for Apollo iOS is CocoaPods.
 
 This will create an `apollo-codegen-config.json` file with the default values.
 
@@ -59,4 +60,4 @@ When using Cocoapods, you will need to manually add the generated files to your
 </ExpansionPanelListItem>
 </ExpansionPanelList>
 
-</ExpansionPanel>
\ No newline at end of file
+</ExpansionPanel>
diff --git a/docs/shared/spm-setup-codegen-panel.mdx b/docs/shared/spm-setup-codegen-panel.mdx
index 2a2166ce0d..660027f77e 100644
--- a/docs/shared/spm-setup-codegen-panel.mdx
+++ b/docs/shared/spm-setup-codegen-panel.mdx
@@ -19,10 +19,11 @@ import SPMInstallCLI from "../shared/spm-install-cli.mdx"
 The Codegen CLI uses a JSON file to configure the code generation engine. Use the Codegen CLI `init` command to create this file with default values. From your project's root directory, run:
 
 ```bash
-./apollo-ios-cli init --schema-name ${MySchemaName}
+./apollo-ios-cli init --schema-name ${MySchemaName} --module-type swiftPackageManager
 ```
 
-`${MySchemaName}` should be the name you want for the namespace of your generated schema files.
+* `${MySchemaName}` should be the name you want for the namespace of your generated schema files.
+* `swiftPackageManager` is the module type to use when your dependency manager for Apollo iOS is Swift Package Manager.
 
 This will create an `apollo-codegen-config.json` file with the default values.
 
diff --git a/docs/source/code-generation/codegen-cli.mdx b/docs/source/code-generation/codegen-cli.mdx
index 366d3d1ff9..cfd925b5c1 100644
--- a/docs/source/code-generation/codegen-cli.mdx
+++ b/docs/source/code-generation/codegen-cli.mdx
@@ -104,13 +104,15 @@ The default configuration will:
 
 #### Command:
 
-`apollo-ios-cli init [--schema-name <schema-name>]`
+`apollo-ios-cli init [--schema-name <schema name>] [--module-type <module type>] [--target-name <target name>]`
 
 #### Options:
 
 | Option     | Description |
 | ---------- | ----------- |
-| `schema-name`       | **[Required]** The name you would like to be used as the namespace for your generated schema files. |
+| `--schema-name`     | **[Required]** The name you would like to be used as the namespace for your generated schema files. |
+| `--module-type`     | **[Required]** How to package the schema types for dependency management. Possible types are `embeddedInTarget`, `swiftPackageManager`, `other`. |
+| `--target-name`     | Name of the target in which the schema types files will be manually embedded.<br/><br/>*Note: This is required for the "embeddedInTarget" module type and will be ignored for all other module types.* |
 | `-p, --path <path>` | Write the configuration to a file at the path. (default: `./apollo-codegen-config.json`) |
 | `-w, --overwrite`   | Overwrite any file at `--path`. If init is called without `--overwrite` and a config file already exists at `--path`, the command will fail. |
 | `-s, --print`       | Print the configuration to stdout. |
diff --git a/docs/source/tutorial/codegen-getting-started.mdx b/docs/source/tutorial/codegen-getting-started.mdx
index b980a7c988..7f3c73f481 100644
--- a/docs/source/tutorial/codegen-getting-started.mdx
+++ b/docs/source/tutorial/codegen-getting-started.mdx
@@ -67,7 +67,7 @@ Download and unzip this file then move the `apollo-ios-cli` binary file into the
 Run the following command:
 
 ```bash
-./apollo-ios-cli init --schema-name StarWarsAPI
+./apollo-ios-cli init --schema-name StarWarsAPI --module-type swiftPackageManager
 ```
 
 The CLI will create a configuration file named `apollo-codegen-configuration.json`, pre-filled with default values.  The file should look similar to this:
@@ -89,14 +89,14 @@ The CLI will create a configuration file named `apollo-codegen-configuration.jso
       }
     },
     "schemaTypes" : {
-      "path" : "./Root",
+      "path" : "./StarWarsAPI",
       "moduleType" : {
         "swiftPackageManager" : {
         }
       }
     },
     "operations" : {
-      "relative" : {
+      "inSchemaModule" : {
       }
     }
   }

From fbcddb712625b25c2c2e931ede2a9a0bcf5f8cda Mon Sep 17 00:00:00 2001
From: Calvin Cestari <calvin.cestari@apollographql.com>
Date: Wed, 16 Nov 2022 21:40:46 -0800
Subject: [PATCH 07/10] Update header doc for new default

---
 Sources/ApolloCodegenLib/ApolloCodegenConfiguration.swift | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Sources/ApolloCodegenLib/ApolloCodegenConfiguration.swift b/Sources/ApolloCodegenLib/ApolloCodegenConfiguration.swift
index f4ce0b3bd9..77fdbd4f67 100644
--- a/Sources/ApolloCodegenLib/ApolloCodegenConfiguration.swift
+++ b/Sources/ApolloCodegenLib/ApolloCodegenConfiguration.swift
@@ -179,7 +179,7 @@ public struct ApolloCodegenConfiguration: Codable, Equatable {
     /// - Parameters:
     ///  - schemaTypes: The local path structure for the generated schema types files.
     ///  - operations: The local path structure for the generated operation object files.
-    ///  Defaults to `.relative` with a `subpath` of `nil`.
+    ///  Defaults to `.inSchemaModule`.
     ///  - testMocks: The local path structure for the test mock operation object files.
     ///  If `.none`, test mocks will not be generated. Defaults to `.none`.
     ///  - operationIdentifiersPath: An absolute location to an operation id JSON map file.

From def919a59d4bb29be2747b180bcfb249154dd872 Mon Sep 17 00:00:00 2001
From: Calvin Cestari <calvin.cestari@apollographql.com>
Date: Wed, 16 Nov 2022 21:44:04 -0800
Subject: [PATCH 08/10] Refactor validation error

---
 Sources/CodegenCLI/Commands/Initialize.swift | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/Sources/CodegenCLI/Commands/Initialize.swift b/Sources/CodegenCLI/Commands/Initialize.swift
index adc5e2c2c6..ebfc551f75 100644
--- a/Sources/CodegenCLI/Commands/Initialize.swift
+++ b/Sources/CodegenCLI/Commands/Initialize.swift
@@ -68,15 +68,13 @@ public struct Initialize: ParsableCommand {
       throw ValidationError("--schema-name value cannot be empty.")
     }
 
-    let targetNameValiationError = ValidationError("""
-      Target name is required when using \"embeddedInTarget\" module type. Use --target-name \
-      to specify.
-      """
-    )
-
     switch (moduleType, targetName?.isEmpty) {
     case (.embeddedInTarget, nil), (.embeddedInTarget, true):
-      throw targetNameValiationError
+      throw ValidationError("""
+        Target name is required when using \"embeddedInTarget\" module type. Use --target-name \
+        to specify.
+        """
+      )
     default:
       break;
     }

From 82717b21d76298453066c2b85f5cf58067efab4d Mon Sep 17 00:00:00 2001
From: Calvin Cestari <calvin.cestari@apollographql.com>
Date: Thu, 17 Nov 2022 12:06:06 -0800
Subject: [PATCH 09/10] Remove extraneous tests

---
 .../Commands/FetchSchemaTests.swift           |  97 ---------
 .../Commands/GenerateTests.swift              | 123 -----------
 .../Commands/InitializeTests.swift            | 203 ------------------
 3 files changed, 423 deletions(-)

diff --git a/Tests/CodegenCLITests/Commands/FetchSchemaTests.swift b/Tests/CodegenCLITests/Commands/FetchSchemaTests.swift
index 1d0aed2299..eee003df56 100644
--- a/Tests/CodegenCLITests/Commands/FetchSchemaTests.swift
+++ b/Tests/CodegenCLITests/Commands/FetchSchemaTests.swift
@@ -24,103 +24,6 @@ class FetchSchemaTests: XCTestCase {
     expect(command.inputs.verbose).to(beFalse())
   }
 
-  func test__parsing__givenParameters_pathLongFormat_shouldParse() throws {
-    // given
-    let path = "/custom/path"
-
-    let options = [
-      "--path=\(path)"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.inputs.path).to(equal(path))
-  }
-
-  func test__parsing__givenParameters_pathShortFormat_shouldParse() throws {
-    // given
-    let path = "/custom/path"
-
-    let options = [
-      "-p=\(path)"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.inputs.path).to(equal(path))
-  }
-
-  func test__parsing__givenParameters_stringLongFormat_shouldParse() throws {
-    // given
-    let string = "could-be-anything"
-
-    let options = [
-      "--string=\(string)"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.inputs.string).to(equal(string))
-  }
-
-  func test__parsing__givenParameters_stringShortFormat_shouldParse() throws {
-    // given
-    let string = "could-be-anything"
-
-    let options = [
-      "-s=\(string)"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.inputs.string).to(equal(string))
-  }
-
-  func test__parsing__givenParameters_verboseLongFormat_shouldParse() throws {
-    // given
-    let options = [
-      "--verbose"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.inputs.verbose).to(beTrue())
-  }
-
-  func test__parsing__givenParameters_verboseShortFormat_shouldParse() throws {
-    // given
-    let options = [
-      "-v"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.inputs.verbose).to(beTrue())
-  }
-
-  func test__parsing__givenParameters_unknown_shouldThrow() throws {
-    // given
-    let options = [
-      "--unknown"
-    ]
-
-    // then
-    expect(try self.parse(options))
-      .to(throwUnknownOptionError())
-  }
-
   // MARK: - FetchSchema Tests
 
   func test__fetchSchema__givenParameters_pathCustom_shouldBuildWithFileData() throws {
diff --git a/Tests/CodegenCLITests/Commands/GenerateTests.swift b/Tests/CodegenCLITests/Commands/GenerateTests.swift
index 7beaa06899..83a0c26078 100644
--- a/Tests/CodegenCLITests/Commands/GenerateTests.swift
+++ b/Tests/CodegenCLITests/Commands/GenerateTests.swift
@@ -25,129 +25,6 @@ class GenerateTests: XCTestCase {
     expect(command.inputs.verbose).to(beFalse())
   }
 
-  func test__parsing__givenParameters_pathLongFormat_shouldParse() throws {
-    // given
-    let path = "/custom/path"
-
-    let options = [
-      "--path=\(path)"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.inputs.path).to(equal(path))
-  }
-
-  func test__parsing__givenParameters_pathShortFormat_shouldParse() throws {
-    // given
-    let path = "/custom/path"
-
-    let options = [
-      "-p=\(path)"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.inputs.path).to(equal(path))
-  }
-
-  func test__parsing__givenParameters_stringLongFormat_shouldParse() throws {
-    // given
-    let string = "could-be-anything"
-
-    let options = [
-      "--string=\(string)"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.inputs.string).to(equal(string))
-  }
-
-  func test__parsing__givenParameters_stringShortFormat_shouldParse() throws {
-    // given
-    let string = "could-be-anything"
-
-    let options = [
-      "-s=\(string)"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.inputs.string).to(equal(string))
-  }
-
-  func test__parsing__givenParameters_fetchSchemaLongFormat_shouldParse() throws {
-    // given
-    let options = [
-      "--fetch-schema"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.fetchSchema).to(beTrue())
-  }
-
-  func test__parsing__givenParameters_fetchSchemaShortFormat_shouldParse() throws {
-    // given
-    let options = [
-      "-f"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.fetchSchema).to(beTrue())
-  }
-
-  func test__parsing__givenParameters_verboseLongFormat_shouldParse() throws {
-    // given
-    let options = [
-      "--verbose"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.inputs.verbose).to(beTrue())
-  }
-
-  func test__parsing__givenParameters_verboseShortFormat_shouldParse() throws {
-    // given
-    let options = [
-      "-v"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.inputs.verbose).to(beTrue())
-  }
-
-  func test__parsing__givenParameters_unknown_shouldThrow() throws {
-    // given
-    let options = [
-      "--unknown"
-    ]
-
-    // then
-    expect(try self.parse(options))
-      .to(throwUnknownOptionError())
-  }
-
   // MARK: - Generate Tests
 
   func test__generate__givenParameters_pathCustom_shouldBuildWithFileData() throws {
diff --git a/Tests/CodegenCLITests/Commands/InitializeTests.swift b/Tests/CodegenCLITests/Commands/InitializeTests.swift
index a51bb5005e..2fd4efd8fb 100644
--- a/Tests/CodegenCLITests/Commands/InitializeTests.swift
+++ b/Tests/CodegenCLITests/Commands/InitializeTests.swift
@@ -32,30 +32,6 @@ class InitializeTests: XCTestCase {
 
   // MARK: - Parsing Tests
 
-  func test__parsing__givenParameters_none_shouldThrow() throws {
-    expect { try self.parse([]) }.to(throwError())
-  }
-
-  func test__parsing__givenParameters_missingSchemaName_shouldThrow() throws {
-    // given
-    let options = [
-      "--module-type=swiftPackageManager",
-    ]
-
-    // when
-    expect { try self.parse(options) }.to(throwError())
-  }
-
-  func test__parsing__givenParameters_missingModuleType_shouldThrow() throws {
-    // given
-    let options = [
-      "--schema-name=MySchemaName",
-    ]
-
-    // when
-    expect { try self.parse(options) }.to(throwError())
-  }
-
   func test__parsing__givenParameters_required_shouldUseDefaults() throws {
     // when
     let command = try parse(requiredOptions)
@@ -66,185 +42,6 @@ class InitializeTests: XCTestCase {
     expect(command.print).to(beFalse())
   }
 
-  func test__parsing__givenParameters_schemaNameLongformat_shouldParse() throws {
-    // given
-    let options = [
-      "--schema-name=LongFormatSchemaName",
-      "--module-type=swiftPackageManager",
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.schemaName).to(equal("LongFormatSchemaName"))
-  }
-
-  func test__parsing__givenParameters_schemaNameShortFormat_shouldParse() throws {
-    // given
-    let options = [
-      "-n=ShortFormatSchemaName",
-      "--module-type=swiftPackageManager",
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.schemaName).to(equal("ShortFormatSchemaName"))
-  }
-
-  func test__parsing__givenParameters_moduleNameLongFormat_shouldParse() throws {
-    // given
-    let options = [
-      "--schema-name=MySchemaName",
-      "--module-type=swiftPackageManager",
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.moduleType).to(equal(.swiftPackageManager))
-  }
-
-  func test__parsing__givenParameters_moduleNameShortFormat_shouldParse() throws {
-    // given
-    let options = [
-      "--schema-name=MySchemaName",
-      "-m=swiftPackageManager",
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.moduleType).to(equal(.swiftPackageManager))
-  }
-
-  func test__parsing__givenParameters_targetNameLongFormat_shouldParse() throws {
-    // given
-    let options = [
-      "--schema-name=MySchemaName",
-      "--module-type=embeddedInTarget",
-      "--target-name=LongFormatTargetName",
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.targetName).to(equal("LongFormatTargetName"))
-  }
-
-  func test__parsing__givenParameters_targetNameShortFormat_shouldParse() throws {
-    // given
-    let options = [
-      "--schema-name=MySchemaName",
-      "--module-type=embeddedInTarget",
-      "-t=ShortFormatTargetName",
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.targetName).to(equal("ShortFormatTargetName"))
-  }
-
-  func test__parsing__givenParameters_pathLongFormat_shouldParse() throws {
-    // given
-    let path = "./configuration.json"
-
-    let options = requiredOptions + [
-      "--path=\(path)"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.path).to(equal(path))
-  }
-
-  func test__parsing__givenParameters_pathShortFormat_shouldParse() throws {
-    // given
-    let path = "./configuration.json"
-
-    let options = requiredOptions + [
-      "-p=\(path)"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.path).to(equal(path))
-  }
-
-  func test__parsing__givenParameters_overwriteLongFormat_shouldParse() throws {
-    // given
-    let options = requiredOptions + [
-      "--overwrite"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.overwrite).to(beTrue())
-  }
-
-  func test__parsing__givenParameters_overwriteShortFormat_shouldParse() throws {
-    // given
-    let options = requiredOptions + [
-      "-w"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.overwrite).to(beTrue())
-  }
-
-  func test__parsing__givenParameters_printLongFormat_shouldParse() throws {
-    // given
-    let options = requiredOptions + [
-      "--print"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.print).to(beTrue())
-  }
-
-  func test__parsing__givenParameters_printShortFormat_shouldParse() throws {
-    // given
-    let options = requiredOptions + [
-      "-s"
-    ]
-
-    // when
-    let command = try parse(options)
-
-    // then
-    expect(command.print).to(beTrue())
-  }
-
-  func test__parsing__givenParameters_unknown_shouldThrow() throws {
-    // given
-    let options = requiredOptions + [
-      "--unknown"
-    ]
-
-    // then
-    expect(try self.parse(options))
-      .to(throwUnknownOptionError())
-  }
-
   // MARK: - Validation Tests
 
   func test__validation__givenWhitespaceSchemaName_shouldThrowValidationError() throws {

From 7a73efd9cfd16ea1685415bff9e9c6786155a5ee Mon Sep 17 00:00:00 2001
From: Calvin Cestari <calvin.cestari@apollographql.com>
Date: Thu, 17 Nov 2022 12:06:40 -0800
Subject: [PATCH 10/10] Update documentation for embeddedInTarget module type
 notes

---
 docs/shared/pods-setup-codegen-panel.mdx | 2 +-
 docs/shared/spm-setup-codegen-panel.mdx  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/docs/shared/pods-setup-codegen-panel.mdx b/docs/shared/pods-setup-codegen-panel.mdx
index 44e718bb98..689dbb05d0 100644
--- a/docs/shared/pods-setup-codegen-panel.mdx
+++ b/docs/shared/pods-setup-codegen-panel.mdx
@@ -16,7 +16,7 @@ The Codegen CLI uses a JSON file to configure the code generation engine. Use th
 ```
 
 * `${MySchemaName}` should be the name you want for the namespace of your generated schema files.
-* `other` is the module type to use when your dependency manager for Apollo iOS is CocoaPods.
+* `embeddedInTarget` or `other` are both suitable module types to use when your dependency manager for Apollo iOS is CocoaPods.
 
 This will create an `apollo-codegen-config.json` file with the default values.
 
diff --git a/docs/shared/spm-setup-codegen-panel.mdx b/docs/shared/spm-setup-codegen-panel.mdx
index 660027f77e..062ebd8dde 100644
--- a/docs/shared/spm-setup-codegen-panel.mdx
+++ b/docs/shared/spm-setup-codegen-panel.mdx
@@ -23,7 +23,7 @@ The Codegen CLI uses a JSON file to configure the code generation engine. Use th
 ```
 
 * `${MySchemaName}` should be the name you want for the namespace of your generated schema files.
-* `swiftPackageManager` is the module type to use when your dependency manager for Apollo iOS is Swift Package Manager.
+* `embeddedInTarget` or `swiftPackageManager` are both suitable module types to use when your dependency manager for Apollo iOS is Swift Package Manager.
 
 This will create an `apollo-codegen-config.json` file with the default values.