Skip to content

Commit

Permalink
Passing all implemented interfaces to object
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdsupremacist committed Jan 4, 2021
1 parent 625b095 commit 90811e9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extension Inline: CustomGraphQLProperty {
}
}

return .interface(interface, fields: fields)
return .interfaces([interface] + object.interfaces, fields: fields)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down

0 comments on commit 90811e9

Please sign in to comment.