Skip to content

Commit 6aea4ed

Browse files
Release - 0.48.0 (#1926)
* Bump version number * Add missing method header documentation * Update changelog * Update documentation
1 parent 704bbf3 commit 6aea4ed

8 files changed

Lines changed: 75 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change log
22

3+
## v0.48.0
4+
- **Customizable subscription message identifiers:** The `WebSocketTransport` initializer can be configured with a subclass of `OperationMessageIdCreator` to provide a unique identifier per request. The default implementation is `ApolloSequencedOperationMessageIdCreator` and retains the current behavior of sequential message numbering. [#1919](https://github.com/apollographql/apollo-ios/pull/1919) - _Thank you to [Clark McNally](https://github.com/cmcnally-beachbody) for the contribution!_
5+
- **AWS AppSync Compatibility:** Apollo-ios will now correctly handle the `start_ack` message that AWS AppSync servers respond with when a subscription is requested. [#1919](https://github.com/apollographql/apollo-ios/pull/1919) - _Thank you to [Clark McNally](https://github.com/cmcnally-beachbody) for the contribution!_
6+
- **Updated to version 2.33.6 of the Apollo CLI:** Applies some new vulnerability patches to the CLI, but should not change any output. [#1929](https://github.com/apollographql/apollo-ios/pull/1929)
7+
- **Improved documentation:** Clarification of cache normalization concepts. [#1710](https://github.com/apollographql/apollo-ios/pull/1710) - _Thank you to [Daniel Morgan](https://github.com/morgz) for the contribution!_
8+
39
## v0.47.1
410
- **Fixed - Websocket default implementation not included in `ApolloWebSocket` via Cocoapods:** _Thank you to [ketenshi](https://github.com/ketenshi) for the contribution!_
511

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
CURRENT_PROJECT_VERSION = 0.47.1
1+
CURRENT_PROJECT_VERSION = 0.48.0

Sources/ApolloWebSocket/OperationMessageIdCreator.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ public protocol OperationMessageIdCreator {
99

1010
// MARK: - Default Implementation
1111

12+
/// The default implementation of `OperationMessageIdCreator` that uses a sequential numbering scheme.
1213
public struct ApolloSequencedOperationMessageIdCreator: OperationMessageIdCreator {
1314
private var sequenceNumberCounter = Atomic<Int>(0)
14-
15-
// Internal init methods cannot be used in public methods
15+
16+
/// Designated initializer.
17+
///
18+
/// - Parameter startAt: The number from which the sequenced numbering scheme should start.
1619
public init(startAt sequenceNumber: Int = 1) {
1720
sequenceNumberCounter = Atomic<Int>(sequenceNumber)
1821
}
19-
22+
23+
/// Returns the number in the current sequence. Will be incremented when calling this method.
2024
public func requestId() -> String {
2125
let id = sequenceNumberCounter.value
2226
_ = sequenceNumberCounter.increment()

Sources/ApolloWebSocket/WebSocketTransport.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ public class WebSocketTransport {
8787
/// - reconnect: Whether to auto reconnect when websocket looses connection. Defaults to true.
8888
/// - reconnectionInterval: How long to wait before attempting to reconnect. Defaults to half a second.
8989
/// - allowSendingDuplicates: Allow sending duplicate messages. Important when reconnected. Defaults to true.
90-
/// - connectOnInit: Whether the websocket connects immediately on creation. If false, remember to call `resumeWebSocketConnection()` to connect. Defaults to true.
90+
/// - connectOnInit: Whether the websocket connects immediately on creation. If false, remember to call `resumeWebSocketConnection()` to connect. Defaults to true.
9191
/// - connectingPayload: [optional] The payload to send on connection. Defaults to an empty `GraphQLMap`.
9292
/// - requestBodyCreator: The `RequestBodyCreator` to use when serializing requests. Defaults to an `ApolloRequestBodyCreator`.
93+
/// - operationMessageIdCreator: The `OperationMessageIdCreator` used to generate a unique message identifier per request. Defaults to `ApolloSequencedOperationMessageIdCreator`.
9394
public init(websocket: WebSocketClient,
9495
store: ApolloStore? = nil,
9596
clientName: String = WebSocketTransport.defaultClientName,

docs/source/api/ApolloWebSocket/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
## Protocols
44

5+
- [OperationMessageIdCreator](protocols/OperationMessageIdCreator/)
56
- [SSLTrustValidator](protocols/SSLTrustValidator/)
67
- [WebSocketClient](protocols/WebSocketClient/)
78
- [WebSocketClientDelegate](protocols/WebSocketClientDelegate/)
89
- [WebSocketTransportDelegate](protocols/WebSocketTransportDelegate/)
910

1011
## Structs
1112

13+
- [ApolloSequencedOperationMessageIdCreator](structs/ApolloSequencedOperationMessageIdCreator/)
1214
- [SSLClientCertificateError](structs/SSLClientCertificateError/)
1315
- [SSLSettings](structs/SSLSettings/)
1416
- [WebSocket.WSError](structs/WebSocket.WSError/)

docs/source/api/ApolloWebSocket/classes/WebSocketTransport.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public var clientVersion: String
3232
- NOTE: Setting this won't override immediately if the socket is still connected, only on reconnection.
3333

3434
## Methods
35-
### `init(websocket:store:clientName:clientVersion:sendOperationIdentifiers:reconnect:reconnectionInterval:allowSendingDuplicates:connectOnInit:connectingPayload:requestBodyCreator:)`
35+
### `init(websocket:store:clientName:clientVersion:sendOperationIdentifiers:reconnect:reconnectionInterval:allowSendingDuplicates:connectOnInit:connectingPayload:requestBodyCreator:operationMessageIdCreator:)`
3636

3737
```swift
3838
public init(websocket: WebSocketClient,
@@ -45,7 +45,8 @@ public init(websocket: WebSocketClient,
4545
allowSendingDuplicates: Bool = true,
4646
connectOnInit: Bool = true,
4747
connectingPayload: GraphQLMap? = [:],
48-
requestBodyCreator: RequestBodyCreator = ApolloRequestBodyCreator())
48+
requestBodyCreator: RequestBodyCreator = ApolloRequestBodyCreator(),
49+
operationMessageIdCreator: OperationMessageIdCreator = ApolloSequencedOperationMessageIdCreator())
4950
```
5051

5152
Designated initializer
@@ -59,9 +60,10 @@ Designated initializer
5960
- reconnect: Whether to auto reconnect when websocket looses connection. Defaults to true.
6061
- reconnectionInterval: How long to wait before attempting to reconnect. Defaults to half a second.
6162
- allowSendingDuplicates: Allow sending duplicate messages. Important when reconnected. Defaults to true.
62-
- connectOnInit: Whether the websocket connects immediately on creation. If false, remember to call `resumeWebSocketConnection()` to connect. Defaults to true.
63+
- connectOnInit: Whether the websocket connects immediately on creation. If false, remember to call `resumeWebSocketConnection()` to connect. Defaults to true.
6364
- connectingPayload: [optional] The payload to send on connection. Defaults to an empty `GraphQLMap`.
6465
- requestBodyCreator: The `RequestBodyCreator` to use when serializing requests. Defaults to an `ApolloRequestBodyCreator`.
66+
- operationMessageIdCreator: The `OperationMessageIdCreator` used to generate a unique message identifier per request. Defaults to `ApolloSequencedOperationMessageIdCreator`.
6567

6668
#### Parameters
6769

@@ -75,6 +77,10 @@ Designated initializer
7577
| reconnect | Whether to auto reconnect when websocket looses connection. Defaults to true. |
7678
| reconnectionInterval | How long to wait before attempting to reconnect. Defaults to half a second. |
7779
| allowSendingDuplicates | Allow sending duplicate messages. Important when reconnected. Defaults to true. |
80+
| connectOnInit | Whether the websocket connects immediately on creation. If false, remember to call `resumeWebSocketConnection()` to connect. Defaults to true. |
81+
| connectingPayload | [optional] The payload to send on connection. Defaults to an empty `GraphQLMap`. |
82+
| requestBodyCreator | The `RequestBodyCreator` to use when serializing requests. Defaults to an `ApolloRequestBodyCreator`. |
83+
| operationMessageIdCreator | The `OperationMessageIdCreator` used to generate a unique message identifier per request. Defaults to `ApolloSequencedOperationMessageIdCreator`. |
7884

7985
### `isConnected()`
8086

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
**PROTOCOL**
2+
3+
# `OperationMessageIdCreator`
4+
5+
```swift
6+
public protocol OperationMessageIdCreator
7+
```
8+
9+
## Methods
10+
### `requestId()`
11+
12+
```swift
13+
func requestId() -> String
14+
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
**STRUCT**
2+
3+
# `ApolloSequencedOperationMessageIdCreator`
4+
5+
```swift
6+
public struct ApolloSequencedOperationMessageIdCreator: OperationMessageIdCreator
7+
```
8+
9+
The default implementation of `OperationMessageIdCreator` that uses a sequential numbering scheme.
10+
11+
## Methods
12+
### `init(startAt:)`
13+
14+
```swift
15+
public init(startAt sequenceNumber: Int = 1)
16+
```
17+
18+
Designated initializer.
19+
20+
- Parameter startAt: The number from which the sequenced numbering scheme should start.
21+
22+
#### Parameters
23+
24+
| Name | Description |
25+
| ---- | ----------- |
26+
| startAt | The number from which the sequenced numbering scheme should start. |
27+
28+
### `requestId()`
29+
30+
```swift
31+
public func requestId() -> String
32+
```
33+
34+
Returns the number in the current sequence. Will be incremented when calling this method.

0 commit comments

Comments
 (0)