Skip to content

Commit a913808

Browse files
feat!: Messenger uses Data
1 parent 9760a33 commit a913808

2 files changed

Lines changed: 3 additions & 17 deletions

File tree

Sources/GraphQLTransportWS/Messenger.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Foundation
44
public protocol Messenger: Sendable {
55
/// Send a message through this messenger
66
/// - Parameter message: The message to send
7-
func send<S: Sendable & Collection>(_ message: S) async throws where S.Element == Character
7+
func send(_ message: Data) async throws
88

99
/// Close the messenger
1010
func close() async throws
@@ -15,15 +15,3 @@ public protocol Messenger: Sendable {
1515
/// - code: An error code
1616
func error(_ message: String, code: Int) async throws
1717
}
18-
19-
extension Messenger {
20-
/// Send a message through this messenger
21-
/// - Parameter message: The message to send
22-
func send(_ message: Data) async throws {
23-
// TODO: Ideally Data is our native interface, and String is the extension.
24-
// Since that change is breaking, we will do it on the next major version.
25-
if let string = String(data: message, encoding: .utf8) {
26-
try await send(string)
27-
}
28-
}
29-
}

Tests/GraphQLTransportWSTests/Utils/TestMessenger.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ actor TestMessenger: Messenger {
1414
self.continuation = continuation
1515
}
1616

17-
func send<S: Sendable & Collection>(_ message: S) async throws where S.Element == Character {
18-
if let data = String(message).data(using: .utf8) {
19-
continuation.yield(data)
20-
}
17+
func send(_ message: Data) async throws {
18+
continuation.yield(message)
2119
}
2220

2321
func error(_ message: String, code: Int) async throws {

0 commit comments

Comments
 (0)