Skip to content

Commit 7d09ffb

Browse files
committed
Network Transport send should not be async
It returns an AsyncThrowingStream that you await for results. But the send function should return that stream synchronously.
1 parent 5149660 commit 7d09ffb

File tree

6 files changed

+13
-10
lines changed

6 files changed

+13
-10
lines changed

apollo-ios/Sources/Apollo/Interceptors/CacheInterceptor.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ public protocol CacheInterceptor: Sendable {
1818

1919
public struct DefaultCacheInterceptor: CacheInterceptor {
2020

21-
let store: ApolloStore
21+
public let store: ApolloStore
22+
23+
public init(store: ApolloStore) {
24+
self.store = store
25+
}
2226

2327
public func readCacheData<Query: GraphQLQuery>(
2428
for query: Query

apollo-ios/Sources/Apollo/Interceptors/MaxRetryInterceptor.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import Foundation
33
import ApolloAPI
44
#endif
55

6-
#warning("TODO: remove unchecked when making interceptor functions async.")
76
/// An interceptor to enforce a maximum number of retries of any `HTTPRequest`
87
public actor MaxRetryInterceptor: ApolloInterceptor, Sendable {
98

apollo-ios/Sources/Apollo/NetworkTransport.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public protocol NetworkTransport: AnyObject, Sendable {
2121
cachePolicy: CachePolicy,
2222
contextIdentifier: UUID?,
2323
context: (any RequestContext)?
24-
) async throws -> AsyncThrowingStream<GraphQLResult<Operation.Data>, any Error>
24+
) throws -> AsyncThrowingStream<GraphQLResult<Operation.Data>, any Error>
2525

2626
}
2727

apollo-ios/Sources/Apollo/RequestChainNetworkTransport.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ public final class RequestChainNetworkTransport: NetworkTransport, Sendable {
113113
public func send<Operation: GraphQLOperation>(
114114
operation: Operation,
115115
cachePolicy: CachePolicy,
116-
contextIdentifier: UUID?,
117-
context: (any RequestContext)?
118-
) async throws -> AsyncThrowingStream<GraphQLResult<Operation.Data>, any Error> {
116+
contextIdentifier: UUID? = nil,
117+
context: (any RequestContext)? = nil
118+
) throws -> AsyncThrowingStream<GraphQLResult<Operation.Data>, any Error> {
119119
let request = self.constructRequest(
120120
for: operation,
121121
cachePolicy: cachePolicy,

apollo-ios/Sources/ApolloWebSocket/SplitNetworkTransport.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ extension SplitNetworkTransport: NetworkTransport {
5353
cachePolicy: CachePolicy,
5454
contextIdentifier: UUID? = nil,
5555
context: (any RequestContext)? = nil
56-
) async throws -> AsyncThrowingStream<GraphQLResult<Operation.Data>, any Error> {
56+
) throws -> AsyncThrowingStream<GraphQLResult<Operation.Data>, any Error> {
5757
if Operation.operationType == .subscription {
58-
return try await webSocketNetworkTransport.send(
58+
return try webSocketNetworkTransport.send(
5959
operation: operation,
6060
cachePolicy: cachePolicy,
6161
contextIdentifier: contextIdentifier,
6262
context: context)
6363
} else {
64-
return try await uploadingNetworkTransport.send(
64+
return try uploadingNetworkTransport.send(
6565
operation: operation,
6666
cachePolicy: cachePolicy,
6767
contextIdentifier: contextIdentifier,

apollo-ios/Sources/ApolloWebSocket/WebSocketTransport.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ extension WebSocketTransport: NetworkTransport {
451451
cachePolicy: CachePolicy,
452452
contextIdentifier: UUID? = nil,
453453
context: (any RequestContext)? = nil
454-
) async throws -> AsyncThrowingStream<GraphQLResult<Operation.Data>, any Error> {
454+
) throws -> AsyncThrowingStream<GraphQLResult<Operation.Data>, any Error> {
455455
if let error = self.error {
456456
return AsyncThrowingStream.init {
457457
throw error

0 commit comments

Comments
 (0)