Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,9 @@ exports[`Swift code generation #structDeclarationForFragment() should generate a
/// The friends of the character, or an empty list if they have none
public var friends: [Friend?]? {
get {
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) } } }
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({
Friend.possibleTypes.contains($0.__typename)
})
}
set {
resultMap.updateValue(newValue.flatMap { (value: [Friend?]) -> [ResultMap?] in value.map { (value: Friend?) -> ResultMap? in value.flatMap { (value: Friend) -> ResultMap in value.resultMap } } }, forKey: \\"friends\\")
Expand Down Expand Up @@ -967,7 +969,9 @@ exports[`Swift code generation #structDeclarationForSelectionSet() should genera
/// The friends of the character, or an empty list if they have none
public var friends: [Friend?]? {
get {
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) } } }
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({
Friend.possibleTypes.contains($0.__typename)
})
}
set {
resultMap.updateValue(newValue.flatMap { (value: [Friend?]) -> [ResultMap?] in value.map { (value: Friend?) -> ResultMap? in value.flatMap { (value: Friend) -> ResultMap in value.resultMap } } }, forKey: \\"friends\\")
Expand Down
10 changes: 9 additions & 1 deletion packages/apollo-codegen-swift/src/codeGeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,15 @@ export class SwiftAPIGenerator extends SwiftGenerator<CompilerContext> {
expression,
"ResultMap",
structName
)}`
)}.filter`
);
this.withinBlock(
() =>
this.printOnNewline(
`${structName}.possibleTypes.contains($0.__typename)`
),
"({",
"})"
);
});
this.printOnNewline("set");
Expand Down