File tree Expand file tree Collapse file tree
packages/apollo-codegen-swift/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1068,7 +1068,9 @@ exports[`Swift code generation #structDeclarationForFragment() should generate a
10681068 // / The friends of the character, or an empty list if they have none
10691069 public var friends : [Friend ? ]? {
10701070 get {
1071- return (resultMap [\\"friends \\"] as ? [ResultMap ?]).flatMap { (value : [ResultMap ? ]) - > [Friend ? ] in value .map { (value : ResultMap ?) -> Friend? in value.flatMap { (value : ResultMap ) - > Friend in Friend (unsafeResultMap : value ) } } }
1071+ return (resultMap [\\"friends \\"] as ? [ResultMap ?]).flatMap { (value : [ResultMap ? ]) - > [Friend ? ] in value .map { (value : ResultMap ?) -> Friend? in value.flatMap { (value : ResultMap ) - > Friend in Friend (unsafeResultMap : value ) } } }.filter ({
1072+ Friend.possibleTypes.contains($0 .__typename )
1073+ })
10721074 }
10731075 set {
10741076 resultMap.updateValue(newValue .flatMap { (value : [Friend ?]) -> [ResultMap ?] in value .map { (value : Friend ?) -> ResultMap ? in value .flatMap { (value : Friend ) -> ResultMap in value .resultMap } } }, forKey : \\" friends\\ " )
@@ -1220,7 +1222,9 @@ exports[`Swift code generation #structDeclarationForSelectionSet() should genera
12201222 // / The friends of the character, or an empty list if they have none
12211223 public var friends : [Friend ? ]? {
12221224 get {
1223- return (resultMap [\\"friends \\"] as ? [ResultMap ?]).flatMap { (value : [ResultMap ? ]) - > [Friend ? ] in value .map { (value : ResultMap ?) -> Friend? in value.flatMap { (value : ResultMap ) - > Friend in Friend (unsafeResultMap : value ) } } }
1225+ return (resultMap [\\"friends \\"] as ? [ResultMap ?]).flatMap { (value : [ResultMap ? ]) - > [Friend ? ] in value .map { (value : ResultMap ?) -> Friend? in value.flatMap { (value : ResultMap ) - > Friend in Friend (unsafeResultMap : value ) } } }.filter ({
1226+ Friend.possibleTypes.contains($0 .__typename )
1227+ })
12241228 }
12251229 set {
12261230 resultMap.updateValue(newValue .flatMap { (value : [Friend ?]) -> [ResultMap ?] in value .map { (value : Friend ?) -> ResultMap ? in value .flatMap { (value : Friend ) -> ResultMap in value .resultMap } } }, forKey : \\" friends\\ " )
Original file line number Diff line number Diff line change @@ -727,7 +727,15 @@ export class SwiftAPIGenerator extends SwiftGenerator<CompilerContext> {
727727 expression ,
728728 "ResultMap" ,
729729 structName
730- ) } `
730+ ) } .filter`
731+ ) ;
732+ this . withinBlock (
733+ ( ) =>
734+ this . printOnNewline (
735+ `${ structName } .possibleTypes.contains($0.__typename)`
736+ ) ,
737+ "({" ,
738+ "})"
731739 ) ;
732740 } ) ;
733741 this . printOnNewline ( "set" ) ;
You can’t perform that action at this time.
0 commit comments