Skip to content

Commit

Permalink
Fixing handling for optional of optionals
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdsupremacist committed May 17, 2021
1 parent 51042a6 commit 3ae6975
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ extension Optional: ValueResolvable where Wrapped: ValueResolvable {
extension Optional: InputResolvable where Wrapped: InputResolvable {

public static func resolve(using context: inout Resolution.Context) throws -> GraphQLInputType {
guard let resolved = try context.resolve(type: Wrapped.self) as? GraphQLNonNull else { fatalError() }
guard let type = resolved.ofType as? GraphQLInputType else { fatalError() }
return type
switch try context.resolve(type: Wrapped.self) {
case let resolved as GraphQLNonNull:
guard let type = resolved.ofType as? GraphQLInputType else { fatalError() }
return type
case let type:
return type
}
}

public static func create(from map: Map) throws -> Optional<Wrapped> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,23 @@ extension Optional: OutputResolvable where Wrapped: OutputResolvable {
}

public static func reference(using context: inout Resolution.Context) throws -> GraphQLOutputType {
guard let resolved = try context.reference(for: Wrapped.self) as? GraphQLNonNull else { fatalError() }
guard let type = resolved.ofType as? GraphQLOutputType else { fatalError() }
return type
switch try context.reference(for: Wrapped.self) {
case let resolved as GraphQLNonNull:
guard let type = resolved.ofType as? GraphQLOutputType else { fatalError() }
return type
case let type:
return type
}
}

public static func resolve(using context: inout Resolution.Context) throws -> GraphQLOutputType {
guard let resolved = try context.resolve(type: Wrapped.self) as? GraphQLNonNull else { fatalError() }
guard let type = resolved.ofType as? GraphQLOutputType else { fatalError() }
return type
switch try context.resolve(type: Wrapped.self) {
case let resolved as GraphQLNonNull:
guard let type = resolved.ofType as? GraphQLOutputType else { fatalError() }
return type
case let type:
return type
}
}

public func resolve(source: Any,
Expand Down

0 comments on commit 3ae6975

Please sign in to comment.