diff --git a/Sources/libAutoGraphCodeGen/FragmentCodeGen.swift b/Sources/libAutoGraphCodeGen/FragmentCodeGen.swift index 7875e57..8b1dda5 100644 --- a/Sources/libAutoGraphCodeGen/FragmentCodeGen.swift +++ b/Sources/libAutoGraphCodeGen/FragmentCodeGen.swift @@ -26,7 +26,7 @@ extension FragmentDefinitionIR { let nextIndentation = indentation + " " let typeDefinition = self.structDeclarationStart(indentation: indentation) let initializer = try self.initializer(indentation: nextIndentation, outputSchemaName: outputSchemaName) - let scalarPropertyDefinitions = try self.selectionSet.genScalarPropertyVariableDeclarations(indentation: nextIndentation, schemaName: outputSchemaName) + let scalarPropertyDefinitions = try self.selectionSet.genScalarPropertyVariableDeclarations(indentation: nextIndentation, schemaName: outputSchemaName, parentFieldBaseTypeName: self.selectionSet.typeInformation.graphQLTypeName.value) let fragmentSpreadPropertyDefinitions = try self.selectionSet.genFragmentSpreadPropertyVariableDeclarations(indentation: nextIndentation, schemaName: outputSchemaName) let (objectSubStructPropertyDefinitions, objectSubStructDefinitions) = try self.selectionSet.genObjectNestedStructDeclarations(indentation: nextIndentation, schemaName: outputSchemaName) diff --git a/Sources/libAutoGraphCodeGen/OperationCodeGen.swift b/Sources/libAutoGraphCodeGen/OperationCodeGen.swift index ac8ff1d..5311cc4 100644 --- a/Sources/libAutoGraphCodeGen/OperationCodeGen.swift +++ b/Sources/libAutoGraphCodeGen/OperationCodeGen.swift @@ -8,7 +8,7 @@ extension OperationDefinitionIR { let nextIndentation = indentation + " " let nextNextIndentation = nextIndentation + " " let initializerAndInputVariableProperties = try self.genInitializerAndInputVariablePropertyDeclarations(indentation: nextIndentation) - let scalarPropertyDefinitions = try self.selectionSet.genScalarPropertyVariableDeclarations(indentation: nextNextIndentation, schemaName: outputSchemaName, omit__typename: true) + let scalarPropertyDefinitions = try self.selectionSet.genScalarPropertyVariableDeclarations(indentation: nextNextIndentation, schemaName: outputSchemaName, parentFieldBaseTypeName: self.typeName, omit__typename: true) let fragmentSpreadPropertyDefinitions = try self.selectionSet.genFragmentSpreadPropertyVariableDeclarations(indentation: nextNextIndentation, schemaName: outputSchemaName) let (objectSubStructPropertyDefinitions, objectSubStructDefinitions) = try self.selectionSet.genObjectNestedStructDeclarations(indentation: nextIndentation, schemaName: outputSchemaName) diff --git a/Sources/libAutoGraphCodeGen/Pipeline/Pipeline.swift b/Sources/libAutoGraphCodeGen/Pipeline/Pipeline.swift index e3ea6ed..84fdebf 100644 --- a/Sources/libAutoGraphCodeGen/Pipeline/Pipeline.swift +++ b/Sources/libAutoGraphCodeGen/Pipeline/Pipeline.swift @@ -60,7 +60,7 @@ public func codeGen(configuration: Configuration) throws { \(optionalInputValueCode) - \(variableInputParamterCode) + \(variableInputParamterCode)\n """ try code.write(toFile: path, atomically: false, encoding: .utf8) } diff --git a/Sources/libAutoGraphCodeGen/SelectionSetCodeGen.swift b/Sources/libAutoGraphCodeGen/SelectionSetCodeGen.swift index 154b201..c313525 100644 --- a/Sources/libAutoGraphCodeGen/SelectionSetCodeGen.swift +++ b/Sources/libAutoGraphCodeGen/SelectionSetCodeGen.swift @@ -66,7 +66,13 @@ extension SelectionSetIR { // MARK: - __typename-injection: let orderedScalarFields = self.scalarFields.ordered(omitting__typename: omit__typename) let scalarParameters = orderedScalarFields.map { - genFunctionParameter(name: $0.swiftVariableIdentifierName, type: $0.swiftVariableTypeIdentifier(schemaName: schemaName)) + let name = $0.swiftVariableIdentifierName + if name == "__typename", let typename = parentFieldBaseTypeName { + return "\(name): String = \"\(typename)\"" + } + else { + return genFunctionParameter(name: name, type: $0.swiftVariableTypeIdentifier(schemaName: schemaName)) + } } let orderedObjectFields = self.objectFields.ordered() @@ -180,10 +186,15 @@ extension SelectionSetIR { return everything.joined(separator: "\n") } - public func genScalarPropertyVariableDeclarations(indentation: String, schemaName: String, omit__typename: Bool = false) throws -> String { + public func genScalarPropertyVariableDeclarations(indentation: String, schemaName: String, parentFieldBaseTypeName: String, omit__typename: Bool = false) throws -> String { // MARK: - __typename-injection: let orderedScalarFields = self.scalarFields.ordered(omitting__typename: omit__typename) - let fields = try orderedScalarFields.map { try $0.genVariableDeclaration(indentation: indentation, schemaName: schemaName) } + let fields = try orderedScalarFields.map { + if $0.swiftVariableIdentifierName == "__typename" { + return "\(indentation)public private(set) var \($0.swiftVariableIdentifierName): String = \"\(parentFieldBaseTypeName)\"" + } + return try $0.genVariableDeclaration(indentation: indentation, schemaName: schemaName) + } return fields.joined(separator: "\n") } @@ -251,7 +262,7 @@ extension SelectionSetIR { let typeDefinition = "\(indentation)public struct \(baseTypeName): Codable {" let nextIndentation = indentation + " " let initializer = try self.genInitializerDeclaration(indentation: nextIndentation, schemaName: schemaName, parentFieldBaseTypeName: baseTypeName) - let innerCode = try self.genPropertyAndNestedStructDeclarations(indentation: nextIndentation, schemaName: schemaName) + let innerCode = try self.genPropertyAndNestedStructDeclarations(indentation: nextIndentation, schemaName: schemaName, parentFieldBaseTypeName: baseTypeName) return """ \(typeDefinition) \(initializer) @@ -278,8 +289,8 @@ extension SelectionSetIR { """ } - public func genPropertyAndNestedStructDeclarations(indentation: String, schemaName: String) throws -> String { - let scalarPropertyVariableDeclarations = try self.genScalarPropertyVariableDeclarations(indentation: indentation, schemaName: schemaName) + public func genPropertyAndNestedStructDeclarations(indentation: String, schemaName: String, parentFieldBaseTypeName: String) throws -> String { + let scalarPropertyVariableDeclarations = try self.genScalarPropertyVariableDeclarations(indentation: indentation, schemaName: schemaName, parentFieldBaseTypeName: parentFieldBaseTypeName) let fragmentSpreadPropertyDefinitions = try self.genFragmentSpreadPropertyVariableDeclarations(indentation: indentation, schemaName: schemaName) let (objectSubStructPropertyDefinitions, objectSubStructDefinitions) = try self.genObjectNestedStructDeclarations(indentation: indentation, schemaName: schemaName) diff --git a/Tests/libAutoGraphCodeGenTests/Products/Shared/GraphQLSchemaRequest.swift b/Tests/libAutoGraphCodeGenTests/Products/Shared/GraphQLSchemaRequest.swift index a69e817..6379a8a 100644 --- a/Tests/libAutoGraphCodeGenTests/Products/Shared/GraphQLSchemaRequest.swift +++ b/Tests/libAutoGraphCodeGenTests/Products/Shared/GraphQLSchemaRequest.swift @@ -166,4 +166,4 @@ extension Array: VariableInputParameterEncodable { } return encoded } -} \ No newline at end of file +} diff --git a/Tests/libAutoGraphCodeGenTests/Products/anilist-gql/AniListGQLSchema.swift b/Tests/libAutoGraphCodeGenTests/Products/anilist-gql/AniListGQLSchema.swift index d7768ce..8f2d626 100644 --- a/Tests/libAutoGraphCodeGenTests/Products/anilist-gql/AniListGQLSchema.swift +++ b/Tests/libAutoGraphCodeGenTests/Products/anilist-gql/AniListGQLSchema.swift @@ -100,7 +100,7 @@ public struct ExampleAniListWithEnumFieldQuery: AutoGraphQLRequest { } public struct Page: Codable { - public init(__typename: String = String(), media: [Page.Media?]? = nil) { + public init(__typename: String = "Page", media: [Page.Media?]? = nil) { self.__typename = __typename self.media = media } @@ -112,12 +112,12 @@ public struct ExampleAniListWithEnumFieldQuery: AutoGraphQLRequest { self.media = try values.decode([Page.Media?]?.self, forKey: .media) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "Page" public private(set) var media: [Media?]? = nil public struct Media: Codable { - public init(__typename: String = String(), description: String? = nil, siteUrl: String? = nil, type: AniListGQLSchema.MediaType? = nil, title: Media.MediaTitle? = nil) { + public init(__typename: String = "Media", description: String? = nil, siteUrl: String? = nil, type: AniListGQLSchema.MediaType? = nil, title: Media.MediaTitle? = nil) { self.__typename = __typename self.description = description self.siteUrl = siteUrl @@ -135,7 +135,7 @@ public struct ExampleAniListWithEnumFieldQuery: AutoGraphQLRequest { self.title = try values.decode(Media.MediaTitle?.self, forKey: .title) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "Media" public private(set) var description: String? = nil public private(set) var siteUrl: String? = nil public private(set) var type: AniListGQLSchema.MediaType? = nil @@ -143,7 +143,7 @@ public struct ExampleAniListWithEnumFieldQuery: AutoGraphQLRequest { public private(set) var title: MediaTitle? = nil public struct MediaTitle: Codable { - public init(__typename: String = String(), english: String? = nil, native: String? = nil) { + public init(__typename: String = "MediaTitle", english: String? = nil, native: String? = nil) { self.__typename = __typename self.english = english self.native = native @@ -157,7 +157,7 @@ public struct ExampleAniListWithEnumFieldQuery: AutoGraphQLRequest { self.native = try values.decode(String?.self, forKey: .native) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "MediaTitle" public private(set) var english: String? = nil public private(set) var native: String? = nil } diff --git a/Tests/libAutoGraphCodeGenTests/Products/poke-gql/PokeGQLSchema.swift b/Tests/libAutoGraphCodeGenTests/Products/poke-gql/PokeGQLSchema.swift index e0af72f..8c8d7b5 100644 --- a/Tests/libAutoGraphCodeGenTests/Products/poke-gql/PokeGQLSchema.swift +++ b/Tests/libAutoGraphCodeGenTests/Products/poke-gql/PokeGQLSchema.swift @@ -71,7 +71,7 @@ public struct ExamplePokemonQuery: AutoGraphQLRequest { } public struct pokemon_v2_ability: Codable { - public init(__typename: String = String(), generation_id: Int? = nil, id: Int = Int(), is_main_series: Bool = Bool(), name: String = String(), pokemon_v2_abilitychanges: [pokemon_v2_ability.pokemon_v2_abilitychange] = []) { + public init(__typename: String = "pokemon_v2_ability", generation_id: Int? = nil, id: Int = Int(), is_main_series: Bool = Bool(), name: String = String(), pokemon_v2_abilitychanges: [pokemon_v2_ability.pokemon_v2_abilitychange] = []) { self.__typename = __typename self.generation_id = generation_id self.id = id @@ -91,7 +91,7 @@ public struct ExamplePokemonQuery: AutoGraphQLRequest { self.pokemon_v2_abilitychanges = try values.decode([pokemon_v2_ability.pokemon_v2_abilitychange].self, forKey: .pokemon_v2_abilitychanges) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "pokemon_v2_ability" public private(set) var generation_id: Int? = nil public private(set) var id: Int = Int() public private(set) var is_main_series: Bool = Bool() @@ -100,7 +100,7 @@ public struct ExamplePokemonQuery: AutoGraphQLRequest { public private(set) var pokemon_v2_abilitychanges: [pokemon_v2_abilitychange] = [] public struct pokemon_v2_abilitychange: Codable { - public init(__typename: String = String(), ability_id: Int? = nil, pokemon_v2_ability: pokemon_v2_abilitychange.pokemon_v2_ability? = nil) { + public init(__typename: String = "pokemon_v2_abilitychange", ability_id: Int? = nil, pokemon_v2_ability: pokemon_v2_abilitychange.pokemon_v2_ability? = nil) { self.__typename = __typename self.ability_id = ability_id self.pokemon_v2_ability = pokemon_v2_ability @@ -114,13 +114,13 @@ public struct ExamplePokemonQuery: AutoGraphQLRequest { self.pokemon_v2_ability = try values.decode(pokemon_v2_abilitychange.pokemon_v2_ability?.self, forKey: .pokemon_v2_ability) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "pokemon_v2_abilitychange" public private(set) var ability_id: Int? = nil public private(set) var pokemon_v2_ability: pokemon_v2_ability? = nil public struct pokemon_v2_ability: Codable { - public init(__typename: String = String(), is_main_series: Bool = Bool(), name: String = String(), pokemon_v2_abilityflavortexts_aggregate: pokemon_v2_ability.pokemon_v2_abilityflavortext_aggregate = pokemon_v2_ability.pokemon_v2_abilityflavortext_aggregate()) { + public init(__typename: String = "pokemon_v2_ability", is_main_series: Bool = Bool(), name: String = String(), pokemon_v2_abilityflavortexts_aggregate: pokemon_v2_ability.pokemon_v2_abilityflavortext_aggregate = pokemon_v2_ability.pokemon_v2_abilityflavortext_aggregate()) { self.__typename = __typename self.is_main_series = is_main_series self.name = name @@ -136,14 +136,14 @@ public struct ExamplePokemonQuery: AutoGraphQLRequest { self.pokemon_v2_abilityflavortexts_aggregate = try values.decode(pokemon_v2_ability.pokemon_v2_abilityflavortext_aggregate.self, forKey: .pokemon_v2_abilityflavortexts_aggregate) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "pokemon_v2_ability" public private(set) var is_main_series: Bool = Bool() public private(set) var name: String = String() public private(set) var pokemon_v2_abilityflavortexts_aggregate: pokemon_v2_abilityflavortext_aggregate = pokemon_v2_abilityflavortext_aggregate() public struct pokemon_v2_abilityflavortext_aggregate: Codable { - public init(__typename: String = String(), aggregate: pokemon_v2_abilityflavortext_aggregate.pokemon_v2_abilityflavortext_aggregate_fields? = nil) { + public init(__typename: String = "pokemon_v2_abilityflavortext_aggregate", aggregate: pokemon_v2_abilityflavortext_aggregate.pokemon_v2_abilityflavortext_aggregate_fields? = nil) { self.__typename = __typename self.aggregate = aggregate } @@ -155,12 +155,12 @@ public struct ExamplePokemonQuery: AutoGraphQLRequest { self.aggregate = try values.decode(pokemon_v2_abilityflavortext_aggregate.pokemon_v2_abilityflavortext_aggregate_fields?.self, forKey: .aggregate) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "pokemon_v2_abilityflavortext_aggregate" public private(set) var aggregate: pokemon_v2_abilityflavortext_aggregate_fields? = nil public struct pokemon_v2_abilityflavortext_aggregate_fields: Codable { - public init(__typename: String = String(), count: Int = Int()) { + public init(__typename: String = "pokemon_v2_abilityflavortext_aggregate_fields", count: Int = Int()) { self.__typename = __typename self.count = count } @@ -172,7 +172,7 @@ public struct ExamplePokemonQuery: AutoGraphQLRequest { self.count = try values.decode(Int.self, forKey: .count) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "pokemon_v2_abilityflavortext_aggregate_fields" public private(set) var count: Int = Int() } } diff --git a/Tests/libAutoGraphCodeGenTests/Products/spacex-gql/SpaceXGQLSchema.swift b/Tests/libAutoGraphCodeGenTests/Products/spacex-gql/SpaceXGQLSchema.swift index 7dd6487..3e07331 100644 --- a/Tests/libAutoGraphCodeGenTests/Products/spacex-gql/SpaceXGQLSchema.swift +++ b/Tests/libAutoGraphCodeGenTests/Products/spacex-gql/SpaceXGQLSchema.swift @@ -312,7 +312,7 @@ public struct ExampleSpaceXQuery: AutoGraphQLRequest { } public struct Info: Codable { - public init(__typename: String = String(), ceo: String? = nil) { + public init(__typename: String = "Info", ceo: String? = nil) { self.__typename = __typename self.ceo = ceo } @@ -324,12 +324,12 @@ public struct ExampleSpaceXQuery: AutoGraphQLRequest { self.ceo = try values.decode(String?.self, forKey: .ceo) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "Info" public private(set) var ceo: String? = nil } public struct Roadster: Codable { - public init(__typename: String = String(), apoapsis_au: Double? = nil) { + public init(__typename: String = "Roadster", apoapsis_au: Double? = nil) { self.__typename = __typename self.apoapsis_au = apoapsis_au } @@ -341,7 +341,7 @@ public struct ExampleSpaceXQuery: AutoGraphQLRequest { self.apoapsis_au = try values.decode(Double?.self, forKey: .apoapsis_au) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "Roadster" public private(set) var apoapsis_au: Double? = nil } } @@ -403,7 +403,7 @@ public struct ExampleSpaceX2Query: AutoGraphQLRequest { } public struct Capsule: Codable { - public init(__typename: String = String(), id: String? = nil, missions: [Capsule.CapsuleMission?]? = nil) { + public init(__typename: String = "Capsule", id: String? = nil, missions: [Capsule.CapsuleMission?]? = nil) { self.__typename = __typename self.id = id self.missions = missions @@ -417,13 +417,13 @@ public struct ExampleSpaceX2Query: AutoGraphQLRequest { self.missions = try values.decode([Capsule.CapsuleMission?]?.self, forKey: .missions) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "Capsule" public private(set) var id: String? = nil public private(set) var missions: [CapsuleMission?]? = nil public struct CapsuleMission: Codable { - public init(__typename: String = String(), flight: Int? = nil, name: String? = nil) { + public init(__typename: String = "CapsuleMission", flight: Int? = nil, name: String? = nil) { self.__typename = __typename self.flight = flight self.name = name @@ -437,14 +437,14 @@ public struct ExampleSpaceX2Query: AutoGraphQLRequest { self.name = try values.decode(String?.self, forKey: .name) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "CapsuleMission" public private(set) var flight: Int? = nil public private(set) var name: String? = nil } } public struct Info: Codable { - public init(__typename: String = String(), ceo: String? = nil) { + public init(__typename: String = "Info", ceo: String? = nil) { self.__typename = __typename self.ceo = ceo } @@ -456,7 +456,7 @@ public struct ExampleSpaceX2Query: AutoGraphQLRequest { self.ceo = try values.decode(String?.self, forKey: .ceo) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "Info" public private(set) var ceo: String? = nil } } @@ -516,7 +516,7 @@ public struct MutationMutation: AutoGraphQLRequest { } public struct users_mutation_response: Codable { - public init(__typename: String = String(), affected_rows: Int = Int(), returning: [users_mutation_response.users] = []) { + public init(__typename: String = "users_mutation_response", affected_rows: Int = Int(), returning: [users_mutation_response.users] = []) { self.__typename = __typename self.affected_rows = affected_rows self.returning = returning @@ -530,13 +530,13 @@ public struct MutationMutation: AutoGraphQLRequest { self.returning = try values.decode([users_mutation_response.users].self, forKey: .returning) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "users_mutation_response" public private(set) var affected_rows: Int = Int() public private(set) var returning: [users] = [] public struct users: Codable { - public init(__typename: String = String(), rocket: String? = nil, timestamp: SpaceXGQLSchema.timestamptz = SpaceXGQLSchema.timestamptz(), twitter: String? = nil) { + public init(__typename: String = "users", rocket: String? = nil, timestamp: SpaceXGQLSchema.timestamptz = SpaceXGQLSchema.timestamptz(), twitter: String? = nil) { self.__typename = __typename self.rocket = rocket self.timestamp = timestamp @@ -552,7 +552,7 @@ public struct MutationMutation: AutoGraphQLRequest { self.twitter = try values.decode(String?.self, forKey: .twitter) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "users" public private(set) var rocket: String? = nil public private(set) var timestamp: SpaceXGQLSchema.timestamptz = SpaceXGQLSchema.timestamptz() public private(set) var twitter: String? = nil @@ -614,7 +614,7 @@ public struct SubscriptionSubscription: AutoGraphQLRequest { } public struct users: Codable { - public init(__typename: String = String(), id: SpaceXGQLSchema.uuid = SpaceXGQLSchema.uuid(), name: String? = nil, rocket: String? = nil, timestamp: SpaceXGQLSchema.timestamptz = SpaceXGQLSchema.timestamptz()) { + public init(__typename: String = "users", id: SpaceXGQLSchema.uuid = SpaceXGQLSchema.uuid(), name: String? = nil, rocket: String? = nil, timestamp: SpaceXGQLSchema.timestamptz = SpaceXGQLSchema.timestamptz()) { self.__typename = __typename self.id = id self.name = name @@ -632,7 +632,7 @@ public struct SubscriptionSubscription: AutoGraphQLRequest { self.timestamp = try values.decode(SpaceXGQLSchema.timestamptz.self, forKey: .timestamp) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "users" public private(set) var id: SpaceXGQLSchema.uuid = SpaceXGQLSchema.uuid() public private(set) var name: String? = nil public private(set) var rocket: String? = nil diff --git a/Tests/libAutoGraphCodeGenTests/Products/swapi-gql/SWAPIGQLSchema.swift b/Tests/libAutoGraphCodeGenTests/Products/swapi-gql/SWAPIGQLSchema.swift index f251109..1e69d10 100644 --- a/Tests/libAutoGraphCodeGenTests/Products/swapi-gql/SWAPIGQLSchema.swift +++ b/Tests/libAutoGraphCodeGenTests/Products/swapi-gql/SWAPIGQLSchema.swift @@ -21,7 +21,7 @@ public enum SWAPIGQLSchema { case pageInfo } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "FilmCharactersConnection" public private(set) var pageInfo: PageInfo = PageInfo() @@ -45,7 +45,7 @@ public enum SWAPIGQLSchema { } public struct PageInfo: Codable { - public init(__typename: String = String(), alias1: Bool = Bool(), hasPreviousPage: Bool = Bool()) { + public init(__typename: String = "PageInfo", alias1: Bool = Bool(), hasPreviousPage: Bool = Bool()) { self.__typename = __typename self.alias1 = alias1 self.hasPreviousPage = hasPreviousPage @@ -59,7 +59,7 @@ public enum SWAPIGQLSchema { self.hasPreviousPage = try values.decode(Bool.self, forKey: .hasPreviousPage) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "PageInfo" public private(set) var alias1: Bool = Bool() public private(set) var hasPreviousPage: Bool = Bool() } @@ -86,7 +86,7 @@ public enum SWAPIGQLSchema { case id } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "Person" public private(set) var birthYear: String? = nil public private(set) var id: String = String() @@ -258,7 +258,7 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { } public struct FilmsConnection: Codable { - public init(__typename: String = String(), edges: [FilmsConnection.FilmsEdge?]? = nil) { + public init(__typename: String = "FilmsConnection", edges: [FilmsConnection.FilmsEdge?]? = nil) { self.__typename = __typename self.edges = edges } @@ -270,12 +270,12 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.edges = try values.decode([FilmsConnection.FilmsEdge?]?.self, forKey: .edges) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "FilmsConnection" public private(set) var edges: [FilmsEdge?]? = nil public struct FilmsEdge: Codable { - public init(__typename: String = String(), node: FilmsEdge.Film? = nil) { + public init(__typename: String = "FilmsEdge", node: FilmsEdge.Film? = nil) { self.__typename = __typename self.node = node } @@ -287,12 +287,12 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.node = try values.decode(FilmsEdge.Film?.self, forKey: .node) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "FilmsEdge" public private(set) var node: Film? = nil public struct Film: Codable { - public init(__typename: String = String(), characterConnection: Film.FilmCharactersConnection? = nil, asFilm: AsFilm? = nil) { + public init(__typename: String = "Film", characterConnection: Film.FilmCharactersConnection? = nil, asFilm: AsFilm? = nil) { self.__typename = __typename self.characterConnection = characterConnection self.asFilm = asFilm @@ -306,14 +306,14 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.asFilm = typename == "Film" ? try AsFilm(from: decoder) : nil } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "Film" public private(set) var characterConnection: FilmCharactersConnection? = nil public private(set) var asFilm: AsFilm? = nil public struct FilmCharactersConnection: Codable { - public init(__typename: String = String(), characters: [FilmCharactersConnection.Person?]? = nil, pageInfo: FilmCharactersConnection.PageInfo = FilmCharactersConnection.PageInfo(), characterConnFrag: SWAPIGQLSchema.CharacterConnFrag = SWAPIGQLSchema.CharacterConnFrag()) { + public init(__typename: String = "FilmCharactersConnection", characters: [FilmCharactersConnection.Person?]? = nil, pageInfo: FilmCharactersConnection.PageInfo = FilmCharactersConnection.PageInfo(), characterConnFrag: SWAPIGQLSchema.CharacterConnFrag = SWAPIGQLSchema.CharacterConnFrag()) { self.__typename = __typename self.characters = characters self.pageInfo = pageInfo @@ -329,7 +329,7 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.characterConnFrag = try SWAPIGQLSchema.CharacterConnFrag(from: decoder) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "FilmCharactersConnection" public private(set) var characters: [Person?]? = nil public private(set) var pageInfo: PageInfo = PageInfo() @@ -337,7 +337,7 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { public private(set) var characterConnFrag: SWAPIGQLSchema.CharacterConnFrag = SWAPIGQLSchema.CharacterConnFrag() public struct Person: Codable { - public init(__typename: String = String(), birthYear: String? = nil, created: String? = nil, edited: String? = nil, eyeColor: String? = nil, homeworld: Person.Planet? = nil, vehicleConnection: Person.PersonVehiclesConnection? = nil) { + public init(__typename: String = "Person", birthYear: String? = nil, created: String? = nil, edited: String? = nil, eyeColor: String? = nil, homeworld: Person.Planet? = nil, vehicleConnection: Person.PersonVehiclesConnection? = nil) { self.__typename = __typename self.birthYear = birthYear self.created = created @@ -359,7 +359,7 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.vehicleConnection = try values.decode(Person.PersonVehiclesConnection?.self, forKey: .vehicleConnection) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "Person" public private(set) var birthYear: String? = nil public private(set) var created: String? = nil public private(set) var edited: String? = nil @@ -369,7 +369,7 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { public private(set) var vehicleConnection: PersonVehiclesConnection? = nil public struct Planet: Codable { - public init(__typename: String = String(), climates: [String?]? = nil, filmConnection: Planet.PlanetFilmsConnection? = nil) { + public init(__typename: String = "Planet", climates: [String?]? = nil, filmConnection: Planet.PlanetFilmsConnection? = nil) { self.__typename = __typename self.climates = climates self.filmConnection = filmConnection @@ -383,13 +383,13 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.filmConnection = try values.decode(Planet.PlanetFilmsConnection?.self, forKey: .filmConnection) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "Planet" public private(set) var climates: [String?]? = nil public private(set) var filmConnection: PlanetFilmsConnection? = nil public struct PlanetFilmsConnection: Codable { - public init(__typename: String = String(), edges: [PlanetFilmsConnection.PlanetFilmsEdge?]? = nil) { + public init(__typename: String = "PlanetFilmsConnection", edges: [PlanetFilmsConnection.PlanetFilmsEdge?]? = nil) { self.__typename = __typename self.edges = edges } @@ -401,12 +401,12 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.edges = try values.decode([PlanetFilmsConnection.PlanetFilmsEdge?]?.self, forKey: .edges) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "PlanetFilmsConnection" public private(set) var edges: [PlanetFilmsEdge?]? = nil public struct PlanetFilmsEdge: Codable { - public init(__typename: String = String(), node: PlanetFilmsEdge.Film? = nil) { + public init(__typename: String = "PlanetFilmsEdge", node: PlanetFilmsEdge.Film? = nil) { self.__typename = __typename self.node = node } @@ -418,12 +418,12 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.node = try values.decode(PlanetFilmsEdge.Film?.self, forKey: .node) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "PlanetFilmsEdge" public private(set) var node: Film? = nil public struct Film: Codable { - public init(__typename: String = String(), characterConnection: Film.FilmCharactersConnection? = nil) { + public init(__typename: String = "Film", characterConnection: Film.FilmCharactersConnection? = nil) { self.__typename = __typename self.characterConnection = characterConnection } @@ -435,12 +435,12 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.characterConnection = try values.decode(Film.FilmCharactersConnection?.self, forKey: .characterConnection) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "Film" public private(set) var characterConnection: FilmCharactersConnection? = nil public struct FilmCharactersConnection: Codable { - public init(__typename: String = String(), characters: [FilmCharactersConnection.Person?]? = nil) { + public init(__typename: String = "FilmCharactersConnection", characters: [FilmCharactersConnection.Person?]? = nil) { self.__typename = __typename self.characters = characters } @@ -452,12 +452,12 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.characters = try values.decode([FilmCharactersConnection.Person?]?.self, forKey: .characters) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "FilmCharactersConnection" public private(set) var characters: [Person?]? = nil public struct Person: Codable { - public init(__typename: String = String(), filmConnection: Person.PersonFilmsConnection? = nil) { + public init(__typename: String = "Person", filmConnection: Person.PersonFilmsConnection? = nil) { self.__typename = __typename self.filmConnection = filmConnection } @@ -469,12 +469,12 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.filmConnection = try values.decode(Person.PersonFilmsConnection?.self, forKey: .filmConnection) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "Person" public private(set) var filmConnection: PersonFilmsConnection? = nil public struct PersonFilmsConnection: Codable { - public init(__typename: String = String(), films: [PersonFilmsConnection.Film?]? = nil) { + public init(__typename: String = "PersonFilmsConnection", films: [PersonFilmsConnection.Film?]? = nil) { self.__typename = __typename self.films = films } @@ -486,12 +486,12 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.films = try values.decode([PersonFilmsConnection.Film?]?.self, forKey: .films) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "PersonFilmsConnection" public private(set) var films: [Film?]? = nil public struct Film: Codable { - public init(__typename: String = String(), episodeID: Int? = nil, id: String = String(), openingCrawl: String? = nil) { + public init(__typename: String = "Film", episodeID: Int? = nil, id: String = String(), openingCrawl: String? = nil) { self.__typename = __typename self.episodeID = episodeID self.id = id @@ -507,7 +507,7 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.openingCrawl = try values.decode(String?.self, forKey: .openingCrawl) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "Film" public private(set) var episodeID: Int? = nil public private(set) var id: String = String() public private(set) var openingCrawl: String? = nil @@ -521,7 +521,7 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { } public struct PersonVehiclesConnection: Codable { - public init(__typename: String = String(), edges: [PersonVehiclesConnection.PersonVehiclesEdge?]? = nil) { + public init(__typename: String = "PersonVehiclesConnection", edges: [PersonVehiclesConnection.PersonVehiclesEdge?]? = nil) { self.__typename = __typename self.edges = edges } @@ -533,12 +533,12 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.edges = try values.decode([PersonVehiclesConnection.PersonVehiclesEdge?]?.self, forKey: .edges) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "PersonVehiclesConnection" public private(set) var edges: [PersonVehiclesEdge?]? = nil public struct PersonVehiclesEdge: Codable { - public init(__typename: String = String(), node: PersonVehiclesEdge.Vehicle? = nil) { + public init(__typename: String = "PersonVehiclesEdge", node: PersonVehiclesEdge.Vehicle? = nil) { self.__typename = __typename self.node = node } @@ -550,12 +550,12 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.node = try values.decode(PersonVehiclesEdge.Vehicle?.self, forKey: .node) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "PersonVehiclesEdge" public private(set) var node: Vehicle? = nil public struct Vehicle: Codable { - public init(__typename: String = String(), crew: String? = nil, edited: String? = nil) { + public init(__typename: String = "Vehicle", crew: String? = nil, edited: String? = nil) { self.__typename = __typename self.crew = crew self.edited = edited @@ -569,7 +569,7 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.edited = try values.decode(String?.self, forKey: .edited) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "Vehicle" public private(set) var crew: String? = nil public private(set) var edited: String? = nil } @@ -578,7 +578,7 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { } public struct PageInfo: Codable { - public init(__typename: String = String(), endCursor: String? = nil, hasNextPage: Bool = Bool(), hasPreviousPage: Bool = Bool(), startCursor: String? = nil) { + public init(__typename: String = "PageInfo", endCursor: String? = nil, hasNextPage: Bool = Bool(), hasPreviousPage: Bool = Bool(), startCursor: String? = nil) { self.__typename = __typename self.endCursor = endCursor self.hasNextPage = hasNextPage @@ -596,7 +596,7 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.startCursor = try values.decode(String?.self, forKey: .startCursor) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "PageInfo" public private(set) var endCursor: String? = nil public private(set) var hasNextPage: Bool = Bool() public private(set) var hasPreviousPage: Bool = Bool() @@ -605,7 +605,7 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { } public struct AsFilm: Codable { - public init(__typename: String = String(), episodeID: Int? = nil) { + public init(__typename: String = "AsFilm", episodeID: Int? = nil) { self.__typename = __typename self.episodeID = episodeID } @@ -617,7 +617,7 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.episodeID = try values.decode(Int?.self, forKey: .episodeID) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "AsFilm" public private(set) var episodeID: Int? = nil } } @@ -625,7 +625,7 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { } public struct Node: Codable { - public init(__typename: String = String(), id: String = String(), asFilm: AsFilm? = nil, asPerson: AsPerson? = nil) { + public init(__typename: String = "Node", id: String = String(), asFilm: AsFilm? = nil, asPerson: AsPerson? = nil) { self.__typename = __typename self.id = id self.asFilm = asFilm @@ -641,14 +641,14 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.asPerson = typename == "Person" ? try AsPerson(from: decoder) : nil } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "Node" public private(set) var id: String = String() public private(set) var asFilm: AsFilm? = nil public private(set) var asPerson: AsPerson? = nil public struct AsFilm: Codable { - public init(__typename: String = String(), director: String? = nil, id: String = String(), planetConnection: AsFilm.FilmPlanetsConnection? = nil) { + public init(__typename: String = "AsFilm", director: String? = nil, id: String = String(), planetConnection: AsFilm.FilmPlanetsConnection? = nil) { self.__typename = __typename self.director = director self.id = id @@ -664,14 +664,14 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.planetConnection = try values.decode(AsFilm.FilmPlanetsConnection?.self, forKey: .planetConnection) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "AsFilm" public private(set) var director: String? = nil public private(set) var id: String = String() public private(set) var planetConnection: FilmPlanetsConnection? = nil public struct FilmPlanetsConnection: Codable { - public init(__typename: String = String(), totalCount: Int? = nil) { + public init(__typename: String = "FilmPlanetsConnection", totalCount: Int? = nil) { self.__typename = __typename self.totalCount = totalCount } @@ -683,13 +683,13 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.totalCount = try values.decode(Int?.self, forKey: .totalCount) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "FilmPlanetsConnection" public private(set) var totalCount: Int? = nil } } public struct AsPerson: Codable { - public init(__typename: String = String(), birthYear: String? = nil, hairColor: String? = nil) { + public init(__typename: String = "AsPerson", birthYear: String? = nil, hairColor: String? = nil) { self.__typename = __typename self.birthYear = birthYear self.hairColor = hairColor @@ -703,7 +703,7 @@ public struct ExampleStarWarsQuery: AutoGraphQLRequest { self.hairColor = try values.decode(String?.self, forKey: .hairColor) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "AsPerson" public private(set) var birthYear: String? = nil public private(set) var hairColor: String? = nil } @@ -757,7 +757,7 @@ public struct TestTopLevelFragmentQuery: AutoGraphQLRequest { } public struct Person: Codable { - public init(__typename: String = String(), personFrag: SWAPIGQLSchema.PersonFrag = SWAPIGQLSchema.PersonFrag()) { + public init(__typename: String = "Person", personFrag: SWAPIGQLSchema.PersonFrag = SWAPIGQLSchema.PersonFrag()) { self.__typename = __typename self.personFrag = personFrag } @@ -769,7 +769,7 @@ public struct TestTopLevelFragmentQuery: AutoGraphQLRequest { self.personFrag = try SWAPIGQLSchema.PersonFrag(from: decoder) } - public private(set) var __typename: String = String() + public private(set) var __typename: String = "Person" public private(set) var personFrag: SWAPIGQLSchema.PersonFrag = SWAPIGQLSchema.PersonFrag() }