File tree Expand file tree Collapse file tree 6 files changed +18
-11
lines changed
Sources/GraphQLTransportWS
Tests/GraphQLTransportWSTests Expand file tree Collapse file tree 6 files changed +18
-11
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public class Client<InitPayload: Equatable & Codable> {
36
36
return
37
37
}
38
38
39
- guard let json = message . data ( using : . utf8) else {
39
+ guard let json = Data ( message . utf8) else {
40
40
self . error ( . invalidEncoding( ) )
41
41
return
42
42
}
@@ -142,6 +142,8 @@ public class Client<InitPayload: Equatable & Codable> {
142
142
)
143
143
}
144
144
145
+ /// Add an observable object for this client that will fire off `Next` messages to the server as updates happen.
146
+ /// - Parameter observable: `Observable<EventLoopFuture<GraphQLRequest>>` to subscribe to for changes.
145
147
public func addObservable( observable: Observable < EventLoopFuture < GraphQLRequest > > ) {
146
148
observable. subscribe (
147
149
onNext: { [ weak self] resultFuture in
Original file line number Diff line number Diff line change 1
1
/// `connection_init` `payload` that is empty
2
- public struct EmptyInitPayload : Equatable & Codable { }
2
+ public struct EmptyInitPayload : Equatable , Codable { }
3
3
4
4
/// `connection_init` `payload` that includes an `authToken` field
5
- public struct TokenInitPayload : Equatable & Codable {
5
+ public struct TokenInitPayload : Equatable , Codable {
6
6
public let authToken : String
7
7
8
8
public init ( authToken: String ) {
Original file line number Diff line number Diff line change @@ -7,17 +7,17 @@ public protocol Messenger: AnyObject {
7
7
8
8
/// Send a message through this messenger
9
9
/// - Parameter message: The message to send
10
- func send< S> ( _ message: S ) -> Void where S: Collection , S. Element == Character
10
+ func send< S> ( _ message: S ) where S: Collection , S. Element == Character
11
11
12
12
/// Set the callback that should be run when a message is recieved
13
- func onReceive( callback: @escaping ( String ) -> Void ) -> Void
13
+ func onReceive( callback: @escaping ( String ) -> Void )
14
14
15
15
/// Close the messenger
16
- func close( ) -> Void
16
+ func close( )
17
17
18
18
/// Indicate that the messenger experienced an error.
19
19
/// - Parameters:
20
20
/// - message: The message describing the error
21
21
/// - code: An error code
22
- func error( _ message: String , code: Int ) -> Void
22
+ func error( _ message: String , code: Int )
23
23
}
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ public class Server<InitPayload: Equatable & Codable> {
51
51
return
52
52
}
53
53
54
- guard let data = message . data ( using : . utf8) else {
54
+ guard let data = Data ( message . utf8) else {
55
55
self . error ( . invalidEncoding( ) )
56
56
return
57
57
}
@@ -197,6 +197,9 @@ public class Server<InitPayload: Equatable & Codable> {
197
197
self . sendError ( result. errors, id: id)
198
198
return
199
199
}
200
+
201
+ // known safe cast
202
+ // swiftlint:disable:next force_cast
200
203
let stream = streamOpt as! ObservableSubscriptionEventStream
201
204
let observable = stream. observable
202
205
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import XCTest
6
6
7
7
@testable import GraphQLTransportWS
8
8
9
- class GraphqlTransportWSTests : XCTestCase {
9
+ final class GraphqlTransportWSTests : XCTestCase {
10
10
var clientMessenger : TestMessenger !
11
11
var serverMessenger : TestMessenger !
12
12
var server : Server < TokenInitPayload > !
@@ -174,7 +174,7 @@ class GraphqlTransportWSTests: XCTestCase {
174
174
}
175
175
176
176
client. onNext { _, _ in
177
- dataIndex = dataIndex + 1
177
+ dataIndex += 1
178
178
if dataIndex <= dataIndexMax {
179
179
pubsub. onNext ( " hello \( dataIndex) " )
180
180
}
@@ -277,7 +277,7 @@ class GraphqlTransportWSTests: XCTestCase {
277
277
}
278
278
279
279
client. onNext { _, _ in
280
- dataIndex = dataIndex + 1
280
+ dataIndex += 1
281
281
if dataIndex <= dataIndexMax {
282
282
pubsub. onNext ( " hello \( dataIndex) " )
283
283
}
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ struct TestAPI: API {
11
11
let resolver = TestResolver ( )
12
12
let context = TestContext ( )
13
13
14
+ // known valid
15
+ // swiftlint:disable:next force_try
14
16
let schema = try ! Schema < TestResolver , TestContext > {
15
17
Query {
16
18
Field ( " hello " , at: TestResolver . hello)
You can’t perform that action at this time.
0 commit comments