Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6e7af18
Implement graphql-transport-ws protocol support
calvincestari Feb 18, 2022
d60ae4a
Add graphql-transport-ws integration test based on Apollo Server docs…
calvincestari Feb 18, 2022
685d359
Add CI step for Apollo Server graphql-transport-ws tests
calvincestari Feb 18, 2022
c36b779
After installing node v12 switch to use v16
calvincestari Feb 18, 2022
b1fc644
Instruct nvm to use version in .nvmrc
calvincestari Feb 18, 2022
6768fde
Update documentation and tutorial
calvincestari Feb 18, 2022
e8d1123
Change WSProtocol cases to closer match library names
calvincestari Feb 21, 2022
7f6c4b6
Remove initializer defaults and require web socket protocol on design…
calvincestari Feb 21, 2022
ad9fbb5
Update Subscriptions documentation
calvincestari Feb 21, 2022
37336c5
Add WSProtocol option for AWS AppSync
calvincestari Feb 22, 2022
348dcf0
Add ping/pong message support required by graphql-ws
calvincestari Feb 22, 2022
3391f33
Update documentation and tutorial
calvincestari Feb 23, 2022
5b3aafb
Add tests for subscriptionWsProtocol
calvincestari Feb 24, 2022
6edea9b
Add tests for graphqlWSProtocol
calvincestari Feb 24, 2022
4178c66
Revert to naming aligned with the protocols and not the implementatio…
calvincestari Feb 24, 2022
d63d078
Use longer async timeout for slower environments like CI
calvincestari Feb 24, 2022
fa3f459
Fix test names
calvincestari Feb 24, 2022
118745d
Fix project configuration
calvincestari Feb 25, 2022
3589cad
Rename protocol parameter on WebSocket initializers
calvincestari Feb 25, 2022
2a92350
Revert "Use longer async timeout for slower environments like CI"
calvincestari Feb 25, 2022
9c92529
Fix async timing bug and refactor websocket protocol tests
calvincestari Feb 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change WSProtocol cases to closer match library names
  • Loading branch information
calvincestari committed Feb 21, 2022
commit e8d1123e6f14cc03728845774dfaf25377f59d6b
19 changes: 10 additions & 9 deletions Sources/ApolloWebSocket/DefaultImplementation/WebSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,16 @@ public final class WebSocket: NSObject, WebSocketClient, StreamDelegate, WebSock

/// The WebSocket sub-protocols supported.
public enum WSProtocol: CustomStringConvertible {
/// Protocol implemented by the graphql-ws library.
case graphql_ws
/// Protocol implemented by the subscriptions-transport-ws libary - considered legacy.
case graphql_transport_ws
/// Protocol implemented in the https://github.com/apollographql/subscriptions-transport-ws
/// library. That library is not actively maintained and considered legacy.
case subscriptionWsProtocol
/// Protocol implemented by the https://github.com/enisdenjo/graphql-ws library.
case graphqlWsProtocol

public var description: String {
switch self {
case .graphql_ws: return "graphql-ws"
case .graphql_transport_ws: return "graphql-transport-ws"
case .subscriptionWsProtocol: return "graphql-ws"
case .graphqlWsProtocol: return "graphql-transport-ws"
}
}
}
Expand Down Expand Up @@ -212,13 +213,13 @@ public final class WebSocket: NSObject, WebSocketClient, StreamDelegate, WebSock
}

if self.request.value(forHTTPHeaderField: Constants.headerWSProtocolName) == nil {
self.request.setValue(WSProtocol.graphql_ws.description,
self.request.setValue(WSProtocol.subscriptionWsProtocol.description,
forHTTPHeaderField: Constants.headerWSProtocolName)
}
writeQueue.maxConcurrentOperationCount = 1
}

public convenience init(url: URL, webSocketProtocol: WSProtocol = .graphql_ws) {
public convenience init(url: URL, webSocketProtocol: WSProtocol = .subscriptionWsProtocol) {
var request = URLRequest(url: url)
request.timeoutInterval = 5
request.setValue(webSocketProtocol.description,
Expand All @@ -231,7 +232,7 @@ public final class WebSocket: NSObject, WebSocketClient, StreamDelegate, WebSock
public convenience init(
url: URL,
writeQueueQOS: QualityOfService,
webSocketProtocol: WSProtocol = .graphql_ws
webSocketProtocol: WSProtocol = .subscriptionWsProtocol
) {
self.init(url: url, webSocketProtocol: webSocketProtocol)
writeQueue.qualityOfService = writeQueueQOS
Expand Down
2 changes: 1 addition & 1 deletion Sources/ApolloWebSocket/WebSocketTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public class WebSocketTransport {
let identifier = operationMessageIdCreator.requestId()

var type: OperationMessage.Types = .start
if case WebSocket.WSProtocol.graphql_transport_ws.description = websocket.request.value(forHTTPHeaderField: WebSocket.Constants.headerWSProtocolName) {
if case WebSocket.WSProtocol.graphqlWsProtocol.description = websocket.request.value(forHTTPHeaderField: WebSocket.Constants.headerWSProtocolName) {
type = .subscribe
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/ApolloServerIntegrationTests/SubscriptionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SubscriptionTests: XCTestCase {
// given
let store = ApolloStore()
let webSocketTransport = WebSocketTransport(
websocket: WebSocket(url: TestServerURL.subscriptionWebSocket.url, webSocketProtocol: .graphql_transport_ws),
websocket: WebSocket(url: TestServerURL.subscriptionWebSocket.url, webSocketProtocol: .graphqlWsProtocol),
store: store
)
webSocketTransport.delegate = self
Expand Down