From 90811e92b130022f008d16fff3d5134e778f943e Mon Sep 17 00:00:00 2001 From: Mathias Quintero Date: Mon, 4 Jan 2021 01:28:56 +0100 Subject: [PATCH] Passing all implemented interfaces to object --- .../Implementations/Object/GraphQLObject+resolve.swift | 2 +- .../Implementations/Object/PropertyWrappers/Inline.swift | 2 +- .../Object/PropertyWrappers/PropertyResult.swift | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/GraphZahl/Resolution/OutputResolvable/Implementations/Object/GraphQLObject+resolve.swift b/Sources/GraphZahl/Resolution/OutputResolvable/Implementations/Object/GraphQLObject+resolve.swift index 601c838..eb41176 100644 --- a/Sources/GraphZahl/Resolution/OutputResolvable/Implementations/Object/GraphQLObject+resolve.swift +++ b/Sources/GraphZahl/Resolution/OutputResolvable/Implementations/Object/GraphQLObject+resolve.swift @@ -20,7 +20,7 @@ extension GraphQLObject { let interfaces = try inheritance .compactMap { $0 as? GraphQLObject.Type } - .map { try context.resolveInterface(object: $0) } + propertyResults.compactMap(\.interface) + .map { try context.resolveInterface(object: $0) } + propertyResults.flatMap(\.interfaces) let type = try GraphQLObjectType(name: concreteTypeName, fields: fields, interfaces: interfaces) { value, _, _ in value is Self } diff --git a/Sources/GraphZahl/Resolution/OutputResolvable/Implementations/Object/PropertyWrappers/Inline.swift b/Sources/GraphZahl/Resolution/OutputResolvable/Implementations/Object/PropertyWrappers/Inline.swift index 5c20d40..7260154 100644 --- a/Sources/GraphZahl/Resolution/OutputResolvable/Implementations/Object/PropertyWrappers/Inline.swift +++ b/Sources/GraphZahl/Resolution/OutputResolvable/Implementations/Object/PropertyWrappers/Inline.swift @@ -38,7 +38,7 @@ extension Inline: CustomGraphQLProperty { } } - return .interface(interface, fields: fields) + return .interfaces([interface] + object.interfaces, fields: fields) } } diff --git a/Sources/GraphZahl/Resolution/OutputResolvable/Implementations/Object/PropertyWrappers/PropertyResult.swift b/Sources/GraphZahl/Resolution/OutputResolvable/Implementations/Object/PropertyWrappers/PropertyResult.swift index c8b151a..79dbdd1 100644 --- a/Sources/GraphZahl/Resolution/OutputResolvable/Implementations/Object/PropertyWrappers/PropertyResult.swift +++ b/Sources/GraphZahl/Resolution/OutputResolvable/Implementations/Object/PropertyWrappers/PropertyResult.swift @@ -3,7 +3,7 @@ import GraphQL enum PropertyResult { case field(String, GraphQLField) - case interface(GraphQLInterfaceType, fields: [String : GraphQLField]) + case interfaces([GraphQLInterfaceType], fields: [String : GraphQLField]) case ignore } @@ -13,15 +13,15 @@ extension PropertyResult { switch self { case .field(let name, let field): return [name : field] - case .interface(_, let fields): + case .interfaces(_, let fields): return fields case .ignore: return [:] } } - var interface: GraphQLInterfaceType? { - guard case .interface(let interface, _) = self else { return nil } + var interfaces: [GraphQLInterfaceType] { + guard case .interfaces(let interface, _) = self else { return [] } return interface }