@@ -652,6 +652,8 @@ public struct ApolloCodegenConfiguration: Codable, Equatable {
652
652
public let operationDocumentFormat : OperationDocumentFormat
653
653
/// Customization options to be applied to the schema during code generation.
654
654
public let schemaCustomization : SchemaCustomization
655
+ /// Whether to reduce the number of schema types that are generated to only those that are referenced in an operation.
656
+ public let reduceGeneratedSchemaTypes : Bool
655
657
/// Generate import statements that are compatible with including `Apollo` via Cocoapods.
656
658
///
657
659
/// Cocoapods bundles all files from subspecs into the main target for a pod. This means that
@@ -703,6 +705,7 @@ public struct ApolloCodegenConfiguration: Codable, Equatable {
703
705
public static let fieldMerging : FieldMerging = [ . all]
704
706
public static let operationDocumentFormat : OperationDocumentFormat = . definition
705
707
public static let schemaCustomization : SchemaCustomization = . init( )
708
+ public static let reduceGeneratedSchemaTypes : Bool = false
706
709
public static let cocoapodsCompatibleImportStatements : Bool = false
707
710
public static let warningsOnDeprecatedUsage : Composition = . include
708
711
public static let conversionStrategies : ConversionStrategies = . init( )
@@ -721,6 +724,8 @@ public struct ApolloCodegenConfiguration: Codable, Equatable {
721
724
/// - selectionSetInitializers: Which generated selection sets should include
722
725
/// generated initializers.
723
726
/// - operationDocumentFormat: How to generate the operation documents for your generated operations.
727
+ /// - schemaCustomization: Customization options to be applied to the schema during code generation.
728
+ /// - reduceGeneratedSchemaTypes: Whether to reduce the number of schema types that are generated to only those that are referenced in an operation.
724
729
/// - cocoapodsCompatibleImportStatements: Generate import statements that are compatible with
725
730
/// including `Apollo` via Cocoapods.
726
731
/// - warningsOnDeprecatedUsage: Annotate generated Swift code with the Swift `available`
@@ -741,6 +746,7 @@ public struct ApolloCodegenConfiguration: Codable, Equatable {
741
746
selectionSetInitializers: SelectionSetInitializers = Default . selectionSetInitializers,
742
747
operationDocumentFormat: OperationDocumentFormat = Default . operationDocumentFormat,
743
748
schemaCustomization: SchemaCustomization = Default . schemaCustomization,
749
+ reduceGeneratedSchemaTypes: Bool = Default . reduceGeneratedSchemaTypes,
744
750
cocoapodsCompatibleImportStatements: Bool = Default . cocoapodsCompatibleImportStatements,
745
751
warningsOnDeprecatedUsage: Composition = Default . warningsOnDeprecatedUsage,
746
752
conversionStrategies: ConversionStrategies = Default . conversionStrategies,
@@ -754,6 +760,7 @@ public struct ApolloCodegenConfiguration: Codable, Equatable {
754
760
self . selectionSetInitializers = selectionSetInitializers
755
761
self . operationDocumentFormat = operationDocumentFormat
756
762
self . schemaCustomization = schemaCustomization
763
+ self . reduceGeneratedSchemaTypes = reduceGeneratedSchemaTypes
757
764
self . cocoapodsCompatibleImportStatements = cocoapodsCompatibleImportStatements
758
765
self . warningsOnDeprecatedUsage = warningsOnDeprecatedUsage
759
766
self . conversionStrategies = conversionStrategies
@@ -773,6 +780,7 @@ public struct ApolloCodegenConfiguration: Codable, Equatable {
773
780
case apqs
774
781
case operationDocumentFormat
775
782
case schemaCustomization
783
+ case reduceGeneratedSchemaTypes
776
784
case cocoapodsCompatibleImportStatements
777
785
case warningsOnDeprecatedUsage
778
786
case conversionStrategies
@@ -819,6 +827,11 @@ public struct ApolloCodegenConfiguration: Codable, Equatable {
819
827
SchemaCustomization . self,
820
828
forKey: . schemaCustomization
821
829
) ?? Default . schemaCustomization
830
+
831
+ reduceGeneratedSchemaTypes = try values. decodeIfPresent (
832
+ Bool . self,
833
+ forKey: . reduceGeneratedSchemaTypes
834
+ ) ?? Default . reduceGeneratedSchemaTypes
822
835
823
836
cocoapodsCompatibleImportStatements = try values. decodeIfPresent (
824
837
Bool . self,
@@ -860,6 +873,7 @@ public struct ApolloCodegenConfiguration: Codable, Equatable {
860
873
try container. encode ( self . selectionSetInitializers, forKey: . selectionSetInitializers)
861
874
try container. encode ( self . operationDocumentFormat, forKey: . operationDocumentFormat)
862
875
try container. encode ( self . schemaCustomization, forKey: . schemaCustomization)
876
+ try container. encode ( self . reduceGeneratedSchemaTypes, forKey: . reduceGeneratedSchemaTypes)
863
877
try container. encode ( self . cocoapodsCompatibleImportStatements, forKey: . cocoapodsCompatibleImportStatements)
864
878
try container. encode ( self . warningsOnDeprecatedUsage, forKey: . warningsOnDeprecatedUsage)
865
879
try container. encode ( self . conversionStrategies, forKey: . conversionStrategies)
@@ -1697,6 +1711,62 @@ extension ApolloCodegenConfiguration.FileOutput {
1697
1711
}
1698
1712
1699
1713
extension ApolloCodegenConfiguration . OutputOptions {
1714
+ /// Deprecated initializer.
1715
+ ///
1716
+ /// - Parameters:
1717
+ /// - additionalInflectionRules: Any non-default rules for pluralization or singularization
1718
+ /// you wish to include.
1719
+ /// - deprecatedEnumCases: How deprecated enum cases from the schema should be handled.
1720
+ /// - schemaDocumentation: Whether schema documentation is added to the generated files.
1721
+ /// - selectionSetInitializers: Which generated selection sets should include
1722
+ /// generated initializers.
1723
+ /// - operationDocumentFormat: How to generate the operation documents for your generated operations.
1724
+ /// - cocoapodsCompatibleImportStatements: Generate import statements that are compatible with
1725
+ /// including `Apollo` via Cocoapods.
1726
+ /// - warningsOnDeprecatedUsage: Annotate generated Swift code with the Swift `available`
1727
+ /// attribute and `deprecated` argument for parts of the GraphQL schema annotated with the
1728
+ /// built-in `@deprecated` directive.
1729
+ /// - conversionStrategies: Rules for how to convert the names of values from the schema in
1730
+ /// generated code.
1731
+ /// - pruneGeneratedFiles: Whether unused generated files will be automatically deleted.
1732
+ /// - markOperationDefinitionsAsFinal: Whether generated GraphQL operation and local cache mutation
1733
+ /// class types will be marked as `final`.
1734
+ /// - appendSchemaTypeFilenameSuffix: `true` will add a filename suffix matching the schema type, the
1735
+ /// default is `false`. This can be used to avoid filename conflicts when operation type names match
1736
+ /// schema type names.
1737
+ ///
1738
+ @available ( * , deprecated,
1739
+ renamed: " init(additionalInflectionRules:queryStringLiteralFormat:deprecatedEnumCases:schemaDocumentation:selectionSetInitializers:operationDocumentFormat:schemaCustomization:reduceGeneratedSchemaTypes:cocoapodsCompatibleImportStatements:warningsOnDeprecatedUsage:conversionStrategies:pruneGeneratedFiles:markOperationDefinitionsAsFinal:appendSchemaTypeFilenameSuffix:) "
1740
+ )
1741
+ public init (
1742
+ additionalInflectionRules: [ InflectionRule ] = Default . additionalInflectionRules,
1743
+ deprecatedEnumCases: ApolloCodegenConfiguration . Composition = Default . deprecatedEnumCases,
1744
+ schemaDocumentation: ApolloCodegenConfiguration . Composition = Default . schemaDocumentation,
1745
+ selectionSetInitializers: ApolloCodegenConfiguration . SelectionSetInitializers = Default . selectionSetInitializers,
1746
+ operationDocumentFormat: ApolloCodegenConfiguration . OperationDocumentFormat = Default . operationDocumentFormat,
1747
+ schemaCustomization: ApolloCodegenConfiguration . SchemaCustomization = Default . schemaCustomization,
1748
+ cocoapodsCompatibleImportStatements: Bool = Default . cocoapodsCompatibleImportStatements,
1749
+ warningsOnDeprecatedUsage: ApolloCodegenConfiguration . Composition = Default . warningsOnDeprecatedUsage,
1750
+ conversionStrategies: ApolloCodegenConfiguration . ConversionStrategies = Default . conversionStrategies,
1751
+ pruneGeneratedFiles: Bool = Default . pruneGeneratedFiles,
1752
+ markOperationDefinitionsAsFinal: Bool = Default . markOperationDefinitionsAsFinal,
1753
+ appendSchemaTypeFilenameSuffix: Bool = Default . appendSchemaTypeFilenameSuffix
1754
+ ) {
1755
+ self . additionalInflectionRules = additionalInflectionRules
1756
+ self . deprecatedEnumCases = deprecatedEnumCases
1757
+ self . schemaDocumentation = schemaDocumentation
1758
+ self . selectionSetInitializers = selectionSetInitializers
1759
+ self . operationDocumentFormat = operationDocumentFormat
1760
+ self . schemaCustomization = schemaCustomization
1761
+ self . reduceGeneratedSchemaTypes = Default . reduceGeneratedSchemaTypes
1762
+ self . cocoapodsCompatibleImportStatements = cocoapodsCompatibleImportStatements
1763
+ self . warningsOnDeprecatedUsage = warningsOnDeprecatedUsage
1764
+ self . conversionStrategies = conversionStrategies
1765
+ self . pruneGeneratedFiles = pruneGeneratedFiles
1766
+ self . markOperationDefinitionsAsFinal = markOperationDefinitionsAsFinal
1767
+ self . appendSchemaTypeFilenameSuffix = appendSchemaTypeFilenameSuffix
1768
+ }
1769
+
1700
1770
/// Deprecated initializer.
1701
1771
///
1702
1772
/// - Parameters:
@@ -1746,6 +1816,7 @@ extension ApolloCodegenConfiguration.OutputOptions {
1746
1816
self . markOperationDefinitionsAsFinal = markOperationDefinitionsAsFinal
1747
1817
self . schemaCustomization = Default . schemaCustomization
1748
1818
self . appendSchemaTypeFilenameSuffix = Default . appendSchemaTypeFilenameSuffix
1819
+ self . reduceGeneratedSchemaTypes = Default . reduceGeneratedSchemaTypes
1749
1820
}
1750
1821
1751
1822
/// Deprecated initializer.
@@ -1797,6 +1868,7 @@ extension ApolloCodegenConfiguration.OutputOptions {
1797
1868
self . markOperationDefinitionsAsFinal = markOperationDefinitionsAsFinal
1798
1869
self . schemaCustomization = Default . schemaCustomization
1799
1870
self . appendSchemaTypeFilenameSuffix = Default . appendSchemaTypeFilenameSuffix
1871
+ self . reduceGeneratedSchemaTypes = Default . reduceGeneratedSchemaTypes
1800
1872
}
1801
1873
1802
1874
/// Whether the generated operations should use Automatic Persisted Queries.
0 commit comments