From 49e53ba04dc8d8446891a4b1888d4b63ceb0607a Mon Sep 17 00:00:00 2001 From: John Clayton Date: Thu, 10 Jun 2021 18:02:40 -0400 Subject: [PATCH 1/9] Initial changes just to get it working with AppSync --- .../ApolloWebSocket/OperationMessage.swift | 3 ++- .../ApolloWebSocket/WebSocketTransport.swift | 19 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Sources/ApolloWebSocket/OperationMessage.swift b/Sources/ApolloWebSocket/OperationMessage.swift index 619cb234b6..35195aa1a2 100644 --- a/Sources/ApolloWebSocket/OperationMessage.swift +++ b/Sources/ApolloWebSocket/OperationMessage.swift @@ -12,6 +12,7 @@ final class OperationMessage { case connectionAck = "connection_ack" // Server -> Client case connectionError = "connection_error" // Server -> Client + case startAck = "start_ack" // Server -> Client case connectionKeepAlive = "ka" // Server -> Client case data = "data" // Server -> Client case error = "error" // Server -> Client @@ -38,7 +39,7 @@ final class OperationMessage { message += ["payload": payload] } if let id = id { - message += ["id": id] + message += ["id": id] } message += ["type": type.rawValue] } diff --git a/Sources/ApolloWebSocket/WebSocketTransport.swift b/Sources/ApolloWebSocket/WebSocketTransport.swift index 2aeb6d4626..45e784c01c 100644 --- a/Sources/ApolloWebSocket/WebSocketTransport.swift +++ b/Sources/ApolloWebSocket/WebSocketTransport.swift @@ -63,7 +63,6 @@ public class WebSocketTransport { private let sendOperationIdentifiers: Bool private let reconnectionInterval: TimeInterval private let allowSendingDuplicates: Bool - fileprivate let sequenceNumberCounter = Atomic(0) fileprivate var reconnected = false /// NOTE: Setting this won't override immediately if the socket is still connected, only on reconnection. @@ -151,9 +150,7 @@ public class WebSocketTransport { switch messageType { case .data, .error: - if - let id = parseHandler.id, - let responseHandler = subscribers[id] { + if let id = parseHandler.id, let responseHandler = subscribers[id] { if let payload = parseHandler.payload { responseHandler(.success(payload)) } else if let error = parseHandler.error { @@ -186,6 +183,9 @@ public class WebSocketTransport { acked = true writeQueue() + case .startAck: + break + case .connectionKeepAlive: writeQueue() @@ -275,22 +275,21 @@ public class WebSocketTransport { sendOperationIdentifiers: self.sendOperationIdentifiers, sendQueryDocument: true, autoPersistQuery: false) - let sequenceNumber = "\(sequenceNumberCounter.increment())" - - guard let message = OperationMessage(payload: body, id: sequenceNumber).rawMessage else { + let identifier = UUID().uuidString + guard let message = OperationMessage(payload: body, id: identifier).rawMessage else { return nil } processingQueue.async { self.write(message) - self.subscribers[sequenceNumber] = resultHandler + self.subscribers[identifier] = resultHandler if operation.operationType == .subscription { - self.subscriptions[sequenceNumber] = message + self.subscriptions[identifier] = message } } - return sequenceNumber + return identifier } public func unsubscribe(_ subscriptionId: String) { From 657ee82b80b718538fc34bef3939d7c10b38f39e Mon Sep 17 00:00:00 2001 From: John Clayton Date: Mon, 14 Jun 2021 12:58:07 -0400 Subject: [PATCH 2/9] Fix project and package so swift package builds correctly --- Apollo.xcodeproj/project.pbxproj | 2 +- Sources/Apollo/GraphQLResponseGenerator.swift | 2 ++ Sources/Apollo/GraphQLResultNormalizer.swift | 2 ++ Sources/Apollo/InputValue+Evaluation.swift | 1 + Sources/ApolloAPI/{CodegenV1 => }/ScalarTypes.swift | 0 5 files changed, 6 insertions(+), 1 deletion(-) rename Sources/ApolloAPI/{CodegenV1 => }/ScalarTypes.swift (100%) diff --git a/Apollo.xcodeproj/project.pbxproj b/Apollo.xcodeproj/project.pbxproj index 2be44cdd54..f4789ca044 100644 --- a/Apollo.xcodeproj/project.pbxproj +++ b/Apollo.xcodeproj/project.pbxproj @@ -1852,6 +1852,7 @@ isa = PBXGroup; children = ( 9FC9A9C11E2D3CAF0023C4D5 /* InputValue.swift */, + DE3C7B15260A6FCA00D2F4FF /* ScalarTypes.swift */, DE3C7B0F260A6F7F00D2F4FF /* CodegenV1 */, DE05862426697A8C00265760 /* Info.plist */, ); @@ -1891,7 +1892,6 @@ DE3C7B14260A6FCA00D2F4FF /* GraphQLEnum.swift */, DE3C7B13260A6FCA00D2F4FF /* GraphQLSchema.swift */, DE3C7B11260A6FC900D2F4FF /* ResponseDict.swift */, - DE3C7B15260A6FCA00D2F4FF /* ScalarTypes.swift */, DE3C7B10260A6FC900D2F4FF /* SelectionSet.swift */, DE664ED326602AF60054DB4F /* Selection.swift */, ); diff --git a/Sources/Apollo/GraphQLResponseGenerator.swift b/Sources/Apollo/GraphQLResponseGenerator.swift index 03d26eb662..07d2e33cd2 100644 --- a/Sources/Apollo/GraphQLResponseGenerator.swift +++ b/Sources/Apollo/GraphQLResponseGenerator.swift @@ -1,3 +1,5 @@ +import Foundation + final class GraphQLResponseGenerator: GraphQLResultAccumulator { func accept(scalar: JSONValue, info: GraphQLResolveInfo) -> JSONValue { return scalar diff --git a/Sources/Apollo/GraphQLResultNormalizer.swift b/Sources/Apollo/GraphQLResultNormalizer.swift index df51676751..0326f9832b 100644 --- a/Sources/Apollo/GraphQLResultNormalizer.swift +++ b/Sources/Apollo/GraphQLResultNormalizer.swift @@ -1,3 +1,5 @@ +import Foundation + final class GraphQLResultNormalizer: GraphQLResultAccumulator { private var records: RecordSet = [:] diff --git a/Sources/Apollo/InputValue+Evaluation.swift b/Sources/Apollo/InputValue+Evaluation.swift index 5b1faddbb7..2e73474463 100644 --- a/Sources/Apollo/InputValue+Evaluation.swift +++ b/Sources/Apollo/InputValue+Evaluation.swift @@ -1,6 +1,7 @@ #if !COCOAPODS import ApolloAPI #endif +import Foundation extension InputValue { func evaluate(with variables: [String: JSONEncodable]?) throws -> JSONValue { diff --git a/Sources/ApolloAPI/CodegenV1/ScalarTypes.swift b/Sources/ApolloAPI/ScalarTypes.swift similarity index 100% rename from Sources/ApolloAPI/CodegenV1/ScalarTypes.swift rename to Sources/ApolloAPI/ScalarTypes.swift From cc48fafe2645a1f3e9b4bd8ed0590c41766ac384 Mon Sep 17 00:00:00 2001 From: Clark McNally Date: Tue, 24 Aug 2021 15:02:56 -0500 Subject: [PATCH 3/9] Add OperationMessageIdCreator to add custom ids --- Apollo.xcodeproj/project.pbxproj | 4 ++++ .../Apollo/OperationMessageIdCreator.swift | 22 +++++++++++++++++++ .../ApolloWebSocket/WebSocketTransport.swift | 9 +++++--- 3 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 Sources/Apollo/OperationMessageIdCreator.swift diff --git a/Apollo.xcodeproj/project.pbxproj b/Apollo.xcodeproj/project.pbxproj index 91ec166978..9ef8ad7155 100644 --- a/Apollo.xcodeproj/project.pbxproj +++ b/Apollo.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 19E9F6A926D5867E003AB80E /* OperationMessageIdCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E9F6A826D5867E003AB80E /* OperationMessageIdCreator.swift */; }; 54DDB0921EA045870009DD99 /* InMemoryNormalizedCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54DDB0911EA045870009DD99 /* InMemoryNormalizedCache.swift */; }; 5AC6CA4322AAF7B200B7C94D /* GraphQLHTTPMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AC6CA4222AAF7B200B7C94D /* GraphQLHTTPMethod.swift */; }; 5BB2C0232380836100774170 /* VersionNumberTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BB2C0222380836100774170 /* VersionNumberTests.swift */; }; @@ -485,6 +486,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 19E9F6A826D5867E003AB80E /* OperationMessageIdCreator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OperationMessageIdCreator.swift; sourceTree = ""; }; 54DDB0911EA045870009DD99 /* InMemoryNormalizedCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InMemoryNormalizedCache.swift; sourceTree = ""; }; 5AC6CA4222AAF7B200B7C94D /* GraphQLHTTPMethod.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphQLHTTPMethod.swift; sourceTree = ""; }; 5BB2C0222380836100774170 /* VersionNumberTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionNumberTests.swift; sourceTree = ""; }; @@ -1523,6 +1525,7 @@ 9BEDC79D22E5D2CF00549BF6 /* RequestBodyCreator.swift */, 9B4F453E244A27B900C2CF7D /* URLSessionClient.swift */, 9B554CC3247DC29A002F452A /* TaskData.swift */, + 19E9F6A826D5867E003AB80E /* OperationMessageIdCreator.swift */, ); name = Network; sourceTree = ""; @@ -2583,6 +2586,7 @@ 9FF90A611DDDEB100034C3B6 /* GraphQLResponse.swift in Sources */, 9BEDC79E22E5D2CF00549BF6 /* RequestBodyCreator.swift in Sources */, 9BE071AD2368D08700FA5952 /* Collection+Helpers.swift in Sources */, + 19E9F6A926D5867E003AB80E /* OperationMessageIdCreator.swift in Sources */, 9FA6F3681E65DF4700BF8D73 /* GraphQLResultAccumulator.swift in Sources */, 9FF90A651DDDEB100034C3B6 /* GraphQLExecutor.swift in Sources */, DE0586362669957800265760 /* CacheReference.swift in Sources */, diff --git a/Sources/Apollo/OperationMessageIdCreator.swift b/Sources/Apollo/OperationMessageIdCreator.swift new file mode 100644 index 0000000000..78013c97ac --- /dev/null +++ b/Sources/Apollo/OperationMessageIdCreator.swift @@ -0,0 +1,22 @@ +import Foundation +#if !COCOAPODS +import ApolloUtils +#endif + +public protocol OperationMessageIdCreator { + func requestId() -> String +} + +// MARK: - Default Implementation + +// Helper struct to create ids independently of HTTP operations. +public struct ApolloOperationMessageIdCreator: OperationMessageIdCreator { + fileprivate let sequenceNumberCounter = Atomic(0) + + // Internal init methods cannot be used in public methods + public init() { } + + public func requestId() -> String { + return "\(sequenceNumberCounter.increment())" + } +} diff --git a/Sources/ApolloWebSocket/WebSocketTransport.swift b/Sources/ApolloWebSocket/WebSocketTransport.swift index 2dc962720d..b0aeb74bdc 100644 --- a/Sources/ApolloWebSocket/WebSocketTransport.swift +++ b/Sources/ApolloWebSocket/WebSocketTransport.swift @@ -33,7 +33,8 @@ public class WebSocketTransport { let error: Atomic = Atomic(nil) let serializationFormat = JSONSerializationFormat.self private let requestBodyCreator: RequestBodyCreator - + private let operationMessageIdCreator: OperationMessageIdCreator + /// non-private for testing - you should not use this directly enum SocketConnectionState { case disconnected @@ -99,7 +100,8 @@ public class WebSocketTransport { allowSendingDuplicates: Bool = true, connectOnInit: Bool = true, connectingPayload: GraphQLMap? = [:], - requestBodyCreator: RequestBodyCreator = ApolloRequestBodyCreator()) { + requestBodyCreator: RequestBodyCreator = ApolloRequestBodyCreator(), + operationMessageIdCreator: OperationMessageIdCreator = ApolloOperationMessageIdCreator()) { self.websocket = websocket self.store = store self.connectingPayload = connectingPayload @@ -108,6 +110,7 @@ public class WebSocketTransport { self.reconnectionInterval = reconnectionInterval self.allowSendingDuplicates = allowSendingDuplicates self.requestBodyCreator = requestBodyCreator + self.operationMessageIdCreator = operationMessageIdCreator self.clientName = clientName self.clientVersion = clientVersion self.connectOnInit = connectOnInit @@ -267,7 +270,7 @@ public class WebSocketTransport { sendOperationIdentifiers: self.sendOperationIdentifiers, sendQueryDocument: true, autoPersistQuery: false) - let identifier = UUID().uuidString + let identifier = operationMessageIdCreator.requestId() guard let message = OperationMessage(payload: body, id: identifier).rawMessage else { return nil } From c284923ae4790ea4b0e492c8bce4e45f1e3a5f68 Mon Sep 17 00:00:00 2001 From: Clark McNally Date: Tue, 24 Aug 2021 16:17:20 -0500 Subject: [PATCH 4/9] Add tests for OperationMessageIdCreator --- Apollo.xcodeproj/project.pbxproj | 8 ++++ .../OperationMessageIdCreatorTests.swift | 32 ++++++++++++++++ .../TestCustomOperationMessageIdCreator.swift | 15 ++++++++ .../WebSocket/WebSocketTests.swift | 38 +++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 Tests/ApolloTests/OperationMessageIdCreatorTests.swift create mode 100644 Tests/ApolloTests/TestCustomOperationMessageIdCreator.swift diff --git a/Apollo.xcodeproj/project.pbxproj b/Apollo.xcodeproj/project.pbxproj index 9ef8ad7155..809ff30c6f 100644 --- a/Apollo.xcodeproj/project.pbxproj +++ b/Apollo.xcodeproj/project.pbxproj @@ -8,6 +8,8 @@ /* Begin PBXBuildFile section */ 19E9F6A926D5867E003AB80E /* OperationMessageIdCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E9F6A826D5867E003AB80E /* OperationMessageIdCreator.swift */; }; + 19E9F6AC26D58A9A003AB80E /* OperationMessageIdCreatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E9F6AA26D58A92003AB80E /* OperationMessageIdCreatorTests.swift */; }; + 19E9F6AE26D58AEC003AB80E /* TestCustomOperationMessageIdCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E9F6AD26D58AEC003AB80E /* TestCustomOperationMessageIdCreator.swift */; }; 54DDB0921EA045870009DD99 /* InMemoryNormalizedCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54DDB0911EA045870009DD99 /* InMemoryNormalizedCache.swift */; }; 5AC6CA4322AAF7B200B7C94D /* GraphQLHTTPMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AC6CA4222AAF7B200B7C94D /* GraphQLHTTPMethod.swift */; }; 5BB2C0232380836100774170 /* VersionNumberTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BB2C0222380836100774170 /* VersionNumberTests.swift */; }; @@ -487,6 +489,8 @@ /* Begin PBXFileReference section */ 19E9F6A826D5867E003AB80E /* OperationMessageIdCreator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OperationMessageIdCreator.swift; sourceTree = ""; }; + 19E9F6AA26D58A92003AB80E /* OperationMessageIdCreatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OperationMessageIdCreatorTests.swift; sourceTree = ""; }; + 19E9F6AD26D58AEC003AB80E /* TestCustomOperationMessageIdCreator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestCustomOperationMessageIdCreator.swift; sourceTree = ""; }; 54DDB0911EA045870009DD99 /* InMemoryNormalizedCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InMemoryNormalizedCache.swift; sourceTree = ""; }; 5AC6CA4222AAF7B200B7C94D /* GraphQLHTTPMethod.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphQLHTTPMethod.swift; sourceTree = ""; }; 5BB2C0222380836100774170 /* VersionNumberTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionNumberTests.swift; sourceTree = ""; }; @@ -984,6 +988,7 @@ 9BF6C91725194D7B000D5B93 /* MultipartFormData+Testing.swift */, 9BC139A724EDCE4F00876D29 /* RetryToCountThenSucceedInterceptor.swift */, 9BF6C99B25195019000D5B93 /* String+IncludesForTesting.swift */, + 19E9F6AD26D58AEC003AB80E /* TestCustomOperationMessageIdCreator.swift */, C3279FC52345233000224790 /* TestCustomRequestBodyCreator.swift */, 9B64F6752354D219002D1BB5 /* URL+QueryDict.swift */, ); @@ -1485,6 +1490,7 @@ 9BF6C95225194EA5000D5B93 /* MultipartFormDataTests.swift */, 9F91CF8E1F6C0DB2008DD0BE /* MutatingResultsTests.swift */, 9F295E301E27534800A24949 /* NormalizeQueryResults.swift */, + 19E9F6AA26D58A92003AB80E /* OperationMessageIdCreatorTests.swift */, 9FF90A6C1DDDEB420034C3B6 /* ParseQueryResponseTests.swift */, 9F21735A2568F3E200566121 /* PossiblyDeferredTests.swift */, F16D083B21EF6F7300C458B8 /* QueryFromJSONBuildingTests.swift */, @@ -2655,6 +2661,8 @@ DED45DE9261B96B70086EF63 /* LoadQueryFromStoreTests.swift in Sources */, 9BF6C94325194DE2000D5B93 /* MultipartFormData+Testing.swift in Sources */, DE181A3426C5D8D4000C0B9C /* CompressionTests.swift in Sources */, + 19E9F6AC26D58A9A003AB80E /* OperationMessageIdCreatorTests.swift in Sources */, + 19E9F6AE26D58AEC003AB80E /* TestCustomOperationMessageIdCreator.swift in Sources */, 9F21735B2568F3E200566121 /* PossiblyDeferredTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Tests/ApolloTests/OperationMessageIdCreatorTests.swift b/Tests/ApolloTests/OperationMessageIdCreatorTests.swift new file mode 100644 index 0000000000..80320faed0 --- /dev/null +++ b/Tests/ApolloTests/OperationMessageIdCreatorTests.swift @@ -0,0 +1,32 @@ +// +// OperationMessageIdCreatorTests.swift +// Apollo +// +// Created by Clark McNally on 8/24/21. +// Copyright © 2021 Apollo GraphQL. All rights reserved. +// + +import XCTest +@testable import Apollo +import UploadAPI + +class OperationMessageIdCreatorTests: XCTestCase { + private let customOperationMessageIdCreator = TestCustomOperationMessageIdCreator() + private let apolloOperationMessageIdCreator = ApolloOperationMessageIdCreator() + + // MARK: - Tests + + func testOperationMessageIdCreatorWithApolloOperationMessageIdCreator() { + let firstId = apolloOperationMessageIdCreator.requestId() + let secondId = apolloOperationMessageIdCreator.requestId() + + XCTAssertEqual(firstId, "1") + XCTAssertEqual(secondId, "2") + } + + func testOperationMessageIdCreatorWithCustomOperationMessageIdCreator() { + let id = customOperationMessageIdCreator.requestId() + + XCTAssertEqual(id, "12345678") + } +} diff --git a/Tests/ApolloTests/TestCustomOperationMessageIdCreator.swift b/Tests/ApolloTests/TestCustomOperationMessageIdCreator.swift new file mode 100644 index 0000000000..10e8e6e69f --- /dev/null +++ b/Tests/ApolloTests/TestCustomOperationMessageIdCreator.swift @@ -0,0 +1,15 @@ +// +// TestCustomOperationMessageIdCreator.swift +// ApolloTests +// +// Created by Clark McNally on 8/24/21. +// Copyright © 2021 Apollo GraphQL. All rights reserved. +// + +import Apollo + +struct TestCustomOperationMessageIdCreator: OperationMessageIdCreator { + func requestId() -> String { + return "12345678" + } +} diff --git a/Tests/ApolloTests/WebSocket/WebSocketTests.swift b/Tests/ApolloTests/WebSocket/WebSocketTests.swift index 1464153362..7e76b88150 100644 --- a/Tests/ApolloTests/WebSocket/WebSocketTests.swift +++ b/Tests/ApolloTests/WebSocket/WebSocketTests.swift @@ -122,4 +122,42 @@ class WebSocketTests: XCTestCase { waitForExpectations(timeout: 2, handler: nil) } + + func testSingleSubscriptionWithCustomOperationMessageIdCreator() throws { + let expectation = self.expectation(description: "Single Subscription with Custom Operation Message Id Creator") + + let store = ApolloStore() + let websocket = MockWebSocket(request:URLRequest(url: TestURL.mockServer.url)) + networkTransport = WebSocketTransport(websocket: websocket, store: store, operationMessageIdCreator: TestCustomOperationMessageIdCreator()) + client = ApolloClient(networkTransport: networkTransport!, store: store) + + client.subscribe(subscription: ReviewAddedSubscription()) { result in + defer { expectation.fulfill() } + switch result { + case .success(let graphQLResult): + XCTAssertEqual(graphQLResult.data?.reviewAdded?.stars, 5) + case .failure(let error): + XCTFail("Unexpected error: \(error)") + } + } + + let message : GraphQLMap = [ + "type": "data", + "id": "12345678", // subscribing on id = 12345678 from custom operation id + "payload": [ + "data": [ + "reviewAdded": [ + "__typename": "ReviewAdded", + "episode": "JEDI", + "stars": 5, + "commentary": "A great movie" + ] + ] + ] + ] + + networkTransport.write(message: message) + + waitForExpectations(timeout: 2, handler: nil) + } } From 3d80b56fa956385bce8b4b08aa1279b01b9714f3 Mon Sep 17 00:00:00 2001 From: Clark McNally Date: Tue, 24 Aug 2021 16:42:22 -0500 Subject: [PATCH 5/9] Fix up project file --- Apollo.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Apollo.xcodeproj/project.pbxproj b/Apollo.xcodeproj/project.pbxproj index 809ff30c6f..684431748d 100644 --- a/Apollo.xcodeproj/project.pbxproj +++ b/Apollo.xcodeproj/project.pbxproj @@ -986,6 +986,7 @@ 9BC139A524EDCAD900876D29 /* BlindRetryingTestInterceptor.swift */, 9B2B66F32513FAFE00B53ABF /* CancellationHandlingInterceptor.swift */, 9BF6C91725194D7B000D5B93 /* MultipartFormData+Testing.swift */, + 19E9F6AA26D58A92003AB80E /* OperationMessageIdCreatorTests.swift */, 9BC139A724EDCE4F00876D29 /* RetryToCountThenSucceedInterceptor.swift */, 9BF6C99B25195019000D5B93 /* String+IncludesForTesting.swift */, 19E9F6AD26D58AEC003AB80E /* TestCustomOperationMessageIdCreator.swift */, @@ -1490,7 +1491,6 @@ 9BF6C95225194EA5000D5B93 /* MultipartFormDataTests.swift */, 9F91CF8E1F6C0DB2008DD0BE /* MutatingResultsTests.swift */, 9F295E301E27534800A24949 /* NormalizeQueryResults.swift */, - 19E9F6AA26D58A92003AB80E /* OperationMessageIdCreatorTests.swift */, 9FF90A6C1DDDEB420034C3B6 /* ParseQueryResponseTests.swift */, 9F21735A2568F3E200566121 /* PossiblyDeferredTests.swift */, F16D083B21EF6F7300C458B8 /* QueryFromJSONBuildingTests.swift */, @@ -1528,10 +1528,10 @@ 9FF90A5B1DDDEB100034C3B6 /* GraphQLResponse.swift */, C377CCAA22D7992E00572E03 /* MultipartFormData.swift */, 9F69FFA81D42855900E000B1 /* NetworkTransport.swift */, + 19E9F6A826D5867E003AB80E /* OperationMessageIdCreator.swift */, 9BEDC79D22E5D2CF00549BF6 /* RequestBodyCreator.swift */, 9B4F453E244A27B900C2CF7D /* URLSessionClient.swift */, 9B554CC3247DC29A002F452A /* TaskData.swift */, - 19E9F6A826D5867E003AB80E /* OperationMessageIdCreator.swift */, ); name = Network; sourceTree = ""; From 8cd1b2c467a0a351943bc1c218b40e38fc8e01ac Mon Sep 17 00:00:00 2001 From: Clark McNally Date: Wed, 25 Aug 2021 13:19:03 -0500 Subject: [PATCH 6/9] Updates from feedback --- Apollo.xcodeproj/project.pbxproj | 8 ++++---- .../OperationMessageIdCreator.swift | 0 Tests/ApolloTests/OperationMessageIdCreatorTests.swift | 8 -------- .../ApolloTests/TestCustomOperationMessageIdCreator.swift | 8 -------- 4 files changed, 4 insertions(+), 20 deletions(-) rename Sources/{Apollo => ApolloWebSocket}/OperationMessageIdCreator.swift (100%) diff --git a/Apollo.xcodeproj/project.pbxproj b/Apollo.xcodeproj/project.pbxproj index 684431748d..bc6470388b 100644 --- a/Apollo.xcodeproj/project.pbxproj +++ b/Apollo.xcodeproj/project.pbxproj @@ -7,9 +7,9 @@ objects = { /* Begin PBXBuildFile section */ - 19E9F6A926D5867E003AB80E /* OperationMessageIdCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E9F6A826D5867E003AB80E /* OperationMessageIdCreator.swift */; }; 19E9F6AC26D58A9A003AB80E /* OperationMessageIdCreatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E9F6AA26D58A92003AB80E /* OperationMessageIdCreatorTests.swift */; }; 19E9F6AE26D58AEC003AB80E /* TestCustomOperationMessageIdCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E9F6AD26D58AEC003AB80E /* TestCustomOperationMessageIdCreator.swift */; }; + 19E9F6B526D6BF25003AB80E /* OperationMessageIdCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E9F6A826D5867E003AB80E /* OperationMessageIdCreator.swift */; }; 54DDB0921EA045870009DD99 /* InMemoryNormalizedCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54DDB0911EA045870009DD99 /* InMemoryNormalizedCache.swift */; }; 5AC6CA4322AAF7B200B7C94D /* GraphQLHTTPMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AC6CA4222AAF7B200B7C94D /* GraphQLHTTPMethod.swift */; }; 5BB2C0232380836100774170 /* VersionNumberTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BB2C0222380836100774170 /* VersionNumberTests.swift */; }; @@ -986,7 +986,6 @@ 9BC139A524EDCAD900876D29 /* BlindRetryingTestInterceptor.swift */, 9B2B66F32513FAFE00B53ABF /* CancellationHandlingInterceptor.swift */, 9BF6C91725194D7B000D5B93 /* MultipartFormData+Testing.swift */, - 19E9F6AA26D58A92003AB80E /* OperationMessageIdCreatorTests.swift */, 9BC139A724EDCE4F00876D29 /* RetryToCountThenSucceedInterceptor.swift */, 9BF6C99B25195019000D5B93 /* String+IncludesForTesting.swift */, 19E9F6AD26D58AEC003AB80E /* TestCustomOperationMessageIdCreator.swift */, @@ -1183,6 +1182,7 @@ children = ( E676C11F26CB05F90091215A /* DefaultImplementation */, 9B7BDA9823FDE94C00ACD198 /* WebSocketClient.swift */, + 19E9F6A826D5867E003AB80E /* OperationMessageIdCreator.swift */, 9B7BDA9723FDE94C00ACD198 /* OperationMessage.swift */, 9B7BDA9623FDE94C00ACD198 /* SplitNetworkTransport.swift */, 9B7BDA9423FDE94C00ACD198 /* WebSocketError.swift */, @@ -1495,6 +1495,7 @@ 9F21735A2568F3E200566121 /* PossiblyDeferredTests.swift */, F16D083B21EF6F7300C458B8 /* QueryFromJSONBuildingTests.swift */, 9FF90A6B1DDDEB420034C3B6 /* ReadFieldValueTests.swift */, + 19E9F6AA26D58A92003AB80E /* OperationMessageIdCreatorTests.swift */, C338DF1622DD9DE9006AF33E /* RequestBodyCreatorTests.swift */, 9B96500824BE6201003C29C0 /* RequestChainTests.swift */, 9B9BBB1A24DB75E60021C30F /* UploadRequestTests.swift */, @@ -1528,7 +1529,6 @@ 9FF90A5B1DDDEB100034C3B6 /* GraphQLResponse.swift */, C377CCAA22D7992E00572E03 /* MultipartFormData.swift */, 9F69FFA81D42855900E000B1 /* NetworkTransport.swift */, - 19E9F6A826D5867E003AB80E /* OperationMessageIdCreator.swift */, 9BEDC79D22E5D2CF00549BF6 /* RequestBodyCreator.swift */, 9B4F453E244A27B900C2CF7D /* URLSessionClient.swift */, 9B554CC3247DC29A002F452A /* TaskData.swift */, @@ -2473,6 +2473,7 @@ 9B7BDA9B23FDE94C00ACD198 /* WebSocketError.swift in Sources */, 9B7BDA9D23FDE94C00ACD198 /* SplitNetworkTransport.swift in Sources */, 9B7BDA9E23FDE94C00ACD198 /* OperationMessage.swift in Sources */, + 19E9F6B526D6BF25003AB80E /* OperationMessageIdCreator.swift in Sources */, DE181A3626C5DE4F000C0B9C /* WebSocketStream.swift in Sources */, DE181A3226C5C401000C0B9C /* Compression.swift in Sources */, ); @@ -2592,7 +2593,6 @@ 9FF90A611DDDEB100034C3B6 /* GraphQLResponse.swift in Sources */, 9BEDC79E22E5D2CF00549BF6 /* RequestBodyCreator.swift in Sources */, 9BE071AD2368D08700FA5952 /* Collection+Helpers.swift in Sources */, - 19E9F6A926D5867E003AB80E /* OperationMessageIdCreator.swift in Sources */, 9FA6F3681E65DF4700BF8D73 /* GraphQLResultAccumulator.swift in Sources */, 9FF90A651DDDEB100034C3B6 /* GraphQLExecutor.swift in Sources */, DE0586362669957800265760 /* CacheReference.swift in Sources */, diff --git a/Sources/Apollo/OperationMessageIdCreator.swift b/Sources/ApolloWebSocket/OperationMessageIdCreator.swift similarity index 100% rename from Sources/Apollo/OperationMessageIdCreator.swift rename to Sources/ApolloWebSocket/OperationMessageIdCreator.swift diff --git a/Tests/ApolloTests/OperationMessageIdCreatorTests.swift b/Tests/ApolloTests/OperationMessageIdCreatorTests.swift index 80320faed0..380611ed32 100644 --- a/Tests/ApolloTests/OperationMessageIdCreatorTests.swift +++ b/Tests/ApolloTests/OperationMessageIdCreatorTests.swift @@ -1,11 +1,3 @@ -// -// OperationMessageIdCreatorTests.swift -// Apollo -// -// Created by Clark McNally on 8/24/21. -// Copyright © 2021 Apollo GraphQL. All rights reserved. -// - import XCTest @testable import Apollo import UploadAPI diff --git a/Tests/ApolloTests/TestCustomOperationMessageIdCreator.swift b/Tests/ApolloTests/TestCustomOperationMessageIdCreator.swift index 10e8e6e69f..601642ae4c 100644 --- a/Tests/ApolloTests/TestCustomOperationMessageIdCreator.swift +++ b/Tests/ApolloTests/TestCustomOperationMessageIdCreator.swift @@ -1,11 +1,3 @@ -// -// TestCustomOperationMessageIdCreator.swift -// ApolloTests -// -// Created by Clark McNally on 8/24/21. -// Copyright © 2021 Apollo GraphQL. All rights reserved. -// - import Apollo struct TestCustomOperationMessageIdCreator: OperationMessageIdCreator { From a369338875033411ee3abbcf7a5645f21f8972bf Mon Sep 17 00:00:00 2001 From: Clark McNally Date: Wed, 25 Aug 2021 13:32:40 -0500 Subject: [PATCH 7/9] Fix unit tests --- Apollo.xcodeproj/project.pbxproj | 4 ++-- .../{ => WebSocket}/OperationMessageIdCreatorTests.swift | 2 +- .../{ => WebSocket}/TestCustomOperationMessageIdCreator.swift | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename Tests/ApolloTests/{ => WebSocket}/OperationMessageIdCreatorTests.swift (95%) rename Tests/ApolloTests/{ => WebSocket}/TestCustomOperationMessageIdCreator.swift (80%) diff --git a/Apollo.xcodeproj/project.pbxproj b/Apollo.xcodeproj/project.pbxproj index bc6470388b..82ac8d59b3 100644 --- a/Apollo.xcodeproj/project.pbxproj +++ b/Apollo.xcodeproj/project.pbxproj @@ -988,7 +988,6 @@ 9BF6C91725194D7B000D5B93 /* MultipartFormData+Testing.swift */, 9BC139A724EDCE4F00876D29 /* RetryToCountThenSucceedInterceptor.swift */, 9BF6C99B25195019000D5B93 /* String+IncludesForTesting.swift */, - 19E9F6AD26D58AEC003AB80E /* TestCustomOperationMessageIdCreator.swift */, C3279FC52345233000224790 /* TestCustomRequestBodyCreator.swift */, 9B64F6752354D219002D1BB5 /* URL+QueryDict.swift */, ); @@ -1495,7 +1494,6 @@ 9F21735A2568F3E200566121 /* PossiblyDeferredTests.swift */, F16D083B21EF6F7300C458B8 /* QueryFromJSONBuildingTests.swift */, 9FF90A6B1DDDEB420034C3B6 /* ReadFieldValueTests.swift */, - 19E9F6AA26D58A92003AB80E /* OperationMessageIdCreatorTests.swift */, C338DF1622DD9DE9006AF33E /* RequestBodyCreatorTests.swift */, 9B96500824BE6201003C29C0 /* RequestChainTests.swift */, 9B9BBB1A24DB75E60021C30F /* UploadRequestTests.swift */, @@ -1733,6 +1731,8 @@ 9B7BDA8A23FDE92900ACD198 /* SplitNetworkTransportTests.swift */, D90F1AF92479DEE5007A1534 /* WebSocketTransportTests.swift */, DE181A3326C5D8D4000C0B9C /* CompressionTests.swift */, + 19E9F6AA26D58A92003AB80E /* OperationMessageIdCreatorTests.swift */, + 19E9F6AD26D58AEC003AB80E /* TestCustomOperationMessageIdCreator.swift */, ); path = WebSocket; sourceTree = ""; diff --git a/Tests/ApolloTests/OperationMessageIdCreatorTests.swift b/Tests/ApolloTests/WebSocket/OperationMessageIdCreatorTests.swift similarity index 95% rename from Tests/ApolloTests/OperationMessageIdCreatorTests.swift rename to Tests/ApolloTests/WebSocket/OperationMessageIdCreatorTests.swift index 380611ed32..23f319844b 100644 --- a/Tests/ApolloTests/OperationMessageIdCreatorTests.swift +++ b/Tests/ApolloTests/WebSocket/OperationMessageIdCreatorTests.swift @@ -1,5 +1,5 @@ import XCTest -@testable import Apollo +@testable import ApolloWebSocket import UploadAPI class OperationMessageIdCreatorTests: XCTestCase { diff --git a/Tests/ApolloTests/TestCustomOperationMessageIdCreator.swift b/Tests/ApolloTests/WebSocket/TestCustomOperationMessageIdCreator.swift similarity index 80% rename from Tests/ApolloTests/TestCustomOperationMessageIdCreator.swift rename to Tests/ApolloTests/WebSocket/TestCustomOperationMessageIdCreator.swift index 601642ae4c..ea38550e4c 100644 --- a/Tests/ApolloTests/TestCustomOperationMessageIdCreator.swift +++ b/Tests/ApolloTests/WebSocket/TestCustomOperationMessageIdCreator.swift @@ -1,4 +1,4 @@ -import Apollo +@testable import ApolloWebSocket struct TestCustomOperationMessageIdCreator: OperationMessageIdCreator { func requestId() -> String { From 6c831045e2f4e958e90138cdfc36175fbdc6c0a0 Mon Sep 17 00:00:00 2001 From: Clark McNally Date: Wed, 25 Aug 2021 16:08:47 -0500 Subject: [PATCH 8/9] Updates from feedback to clean up OperationMessageIdCreator and tests --- Apollo.xcodeproj/project.pbxproj | 4 ---- .../OperationMessageIdCreator.swift | 14 +++++++++----- .../ApolloWebSocket/WebSocketTransport.swift | 2 +- .../OperationMessageIdCreatorTests.swift | 17 ++++++++++++----- .../TestCustomOperationMessageIdCreator.swift | 7 ------- .../ApolloTests/WebSocket/WebSocketTests.swift | 8 +++++++- 6 files changed, 29 insertions(+), 23 deletions(-) delete mode 100644 Tests/ApolloTests/WebSocket/TestCustomOperationMessageIdCreator.swift diff --git a/Apollo.xcodeproj/project.pbxproj b/Apollo.xcodeproj/project.pbxproj index 82ac8d59b3..1f898c1667 100644 --- a/Apollo.xcodeproj/project.pbxproj +++ b/Apollo.xcodeproj/project.pbxproj @@ -8,7 +8,6 @@ /* Begin PBXBuildFile section */ 19E9F6AC26D58A9A003AB80E /* OperationMessageIdCreatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E9F6AA26D58A92003AB80E /* OperationMessageIdCreatorTests.swift */; }; - 19E9F6AE26D58AEC003AB80E /* TestCustomOperationMessageIdCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E9F6AD26D58AEC003AB80E /* TestCustomOperationMessageIdCreator.swift */; }; 19E9F6B526D6BF25003AB80E /* OperationMessageIdCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E9F6A826D5867E003AB80E /* OperationMessageIdCreator.swift */; }; 54DDB0921EA045870009DD99 /* InMemoryNormalizedCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54DDB0911EA045870009DD99 /* InMemoryNormalizedCache.swift */; }; 5AC6CA4322AAF7B200B7C94D /* GraphQLHTTPMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AC6CA4222AAF7B200B7C94D /* GraphQLHTTPMethod.swift */; }; @@ -490,7 +489,6 @@ /* Begin PBXFileReference section */ 19E9F6A826D5867E003AB80E /* OperationMessageIdCreator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OperationMessageIdCreator.swift; sourceTree = ""; }; 19E9F6AA26D58A92003AB80E /* OperationMessageIdCreatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OperationMessageIdCreatorTests.swift; sourceTree = ""; }; - 19E9F6AD26D58AEC003AB80E /* TestCustomOperationMessageIdCreator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestCustomOperationMessageIdCreator.swift; sourceTree = ""; }; 54DDB0911EA045870009DD99 /* InMemoryNormalizedCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InMemoryNormalizedCache.swift; sourceTree = ""; }; 5AC6CA4222AAF7B200B7C94D /* GraphQLHTTPMethod.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphQLHTTPMethod.swift; sourceTree = ""; }; 5BB2C0222380836100774170 /* VersionNumberTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionNumberTests.swift; sourceTree = ""; }; @@ -1732,7 +1730,6 @@ D90F1AF92479DEE5007A1534 /* WebSocketTransportTests.swift */, DE181A3326C5D8D4000C0B9C /* CompressionTests.swift */, 19E9F6AA26D58A92003AB80E /* OperationMessageIdCreatorTests.swift */, - 19E9F6AD26D58AEC003AB80E /* TestCustomOperationMessageIdCreator.swift */, ); path = WebSocket; sourceTree = ""; @@ -2662,7 +2659,6 @@ 9BF6C94325194DE2000D5B93 /* MultipartFormData+Testing.swift in Sources */, DE181A3426C5D8D4000C0B9C /* CompressionTests.swift in Sources */, 19E9F6AC26D58A9A003AB80E /* OperationMessageIdCreatorTests.swift in Sources */, - 19E9F6AE26D58AEC003AB80E /* TestCustomOperationMessageIdCreator.swift in Sources */, 9F21735B2568F3E200566121 /* PossiblyDeferredTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Sources/ApolloWebSocket/OperationMessageIdCreator.swift b/Sources/ApolloWebSocket/OperationMessageIdCreator.swift index 78013c97ac..a34a0ebaf7 100644 --- a/Sources/ApolloWebSocket/OperationMessageIdCreator.swift +++ b/Sources/ApolloWebSocket/OperationMessageIdCreator.swift @@ -9,14 +9,18 @@ public protocol OperationMessageIdCreator { // MARK: - Default Implementation -// Helper struct to create ids independently of HTTP operations. -public struct ApolloOperationMessageIdCreator: OperationMessageIdCreator { - fileprivate let sequenceNumberCounter = Atomic(0) +public struct ApolloSequencedOperationMessageIdCreator: OperationMessageIdCreator { + private var sequenceNumberCounter = Atomic(0) // Internal init methods cannot be used in public methods - public init() { } + public init(startAt sequenceNumber: Int = 1) { + sequenceNumberCounter = Atomic(sequenceNumber) + } public func requestId() -> String { - return "\(sequenceNumberCounter.increment())" + let id = sequenceNumberCounter.value + _ = sequenceNumberCounter.increment() + + return "\(id)" } } diff --git a/Sources/ApolloWebSocket/WebSocketTransport.swift b/Sources/ApolloWebSocket/WebSocketTransport.swift index b0aeb74bdc..479b0588a7 100644 --- a/Sources/ApolloWebSocket/WebSocketTransport.swift +++ b/Sources/ApolloWebSocket/WebSocketTransport.swift @@ -101,7 +101,7 @@ public class WebSocketTransport { connectOnInit: Bool = true, connectingPayload: GraphQLMap? = [:], requestBodyCreator: RequestBodyCreator = ApolloRequestBodyCreator(), - operationMessageIdCreator: OperationMessageIdCreator = ApolloOperationMessageIdCreator()) { + operationMessageIdCreator: OperationMessageIdCreator = ApolloSequencedOperationMessageIdCreator()) { self.websocket = websocket self.store = store self.connectingPayload = connectingPayload diff --git a/Tests/ApolloTests/WebSocket/OperationMessageIdCreatorTests.swift b/Tests/ApolloTests/WebSocket/OperationMessageIdCreatorTests.swift index 23f319844b..6c4381eaeb 100644 --- a/Tests/ApolloTests/WebSocket/OperationMessageIdCreatorTests.swift +++ b/Tests/ApolloTests/WebSocket/OperationMessageIdCreatorTests.swift @@ -3,20 +3,27 @@ import XCTest import UploadAPI class OperationMessageIdCreatorTests: XCTestCase { - private let customOperationMessageIdCreator = TestCustomOperationMessageIdCreator() - private let apolloOperationMessageIdCreator = ApolloOperationMessageIdCreator() - + struct CustomOperationMessageIdCreator: OperationMessageIdCreator { + func requestId() -> String { + return "12345678" + } + } + // MARK: - Tests func testOperationMessageIdCreatorWithApolloOperationMessageIdCreator() { + let apolloOperationMessageIdCreator = ApolloSequencedOperationMessageIdCreator(startAt: 5) + let firstId = apolloOperationMessageIdCreator.requestId() let secondId = apolloOperationMessageIdCreator.requestId() - XCTAssertEqual(firstId, "1") - XCTAssertEqual(secondId, "2") + XCTAssertEqual(firstId, "5") + XCTAssertEqual(secondId, "6") } func testOperationMessageIdCreatorWithCustomOperationMessageIdCreator() { + let customOperationMessageIdCreator = CustomOperationMessageIdCreator() + let id = customOperationMessageIdCreator.requestId() XCTAssertEqual(id, "12345678") diff --git a/Tests/ApolloTests/WebSocket/TestCustomOperationMessageIdCreator.swift b/Tests/ApolloTests/WebSocket/TestCustomOperationMessageIdCreator.swift deleted file mode 100644 index ea38550e4c..0000000000 --- a/Tests/ApolloTests/WebSocket/TestCustomOperationMessageIdCreator.swift +++ /dev/null @@ -1,7 +0,0 @@ -@testable import ApolloWebSocket - -struct TestCustomOperationMessageIdCreator: OperationMessageIdCreator { - func requestId() -> String { - return "12345678" - } -} diff --git a/Tests/ApolloTests/WebSocket/WebSocketTests.swift b/Tests/ApolloTests/WebSocket/WebSocketTests.swift index 7e76b88150..a6d610aa99 100644 --- a/Tests/ApolloTests/WebSocket/WebSocketTests.swift +++ b/Tests/ApolloTests/WebSocket/WebSocketTests.swift @@ -18,6 +18,12 @@ class WebSocketTests: XCTestCase { var client: ApolloClient! var websocket: MockWebSocket! + struct CustomOperationMessageIdCreator: OperationMessageIdCreator { + func requestId() -> String { + return "12345678" + } + } + override func setUp() { super.setUp() @@ -128,7 +134,7 @@ class WebSocketTests: XCTestCase { let store = ApolloStore() let websocket = MockWebSocket(request:URLRequest(url: TestURL.mockServer.url)) - networkTransport = WebSocketTransport(websocket: websocket, store: store, operationMessageIdCreator: TestCustomOperationMessageIdCreator()) + networkTransport = WebSocketTransport(websocket: websocket, store: store, operationMessageIdCreator: CustomOperationMessageIdCreator()) client = ApolloClient(networkTransport: networkTransport!, store: store) client.subscribe(subscription: ReviewAddedSubscription()) { result in From 71ef4c78fa08d560f20fabb9c69dd3b4c25d0185 Mon Sep 17 00:00:00 2001 From: Clark McNally Date: Thu, 26 Aug 2021 08:38:20 -0500 Subject: [PATCH 9/9] Update to group startAck with connectionKeepAlive --- Sources/ApolloWebSocket/WebSocketTransport.swift | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Sources/ApolloWebSocket/WebSocketTransport.swift b/Sources/ApolloWebSocket/WebSocketTransport.swift index 479b0588a7..37dcbebd68 100644 --- a/Sources/ApolloWebSocket/WebSocketTransport.swift +++ b/Sources/ApolloWebSocket/WebSocketTransport.swift @@ -178,10 +178,8 @@ public class WebSocketTransport { acked = true writeQueue() - case .startAck: - break - - case .connectionKeepAlive: + case .connectionKeepAlive, + .startAck: writeQueue() case .connectionInit,