Skip to content

Commit 1abaeea

Browse files
add some extra hints around new error delegate
1 parent 3f962d7 commit 1abaeea

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

Sources/Apollo/HTTPNetworkTransport.swift

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public protocol HTTPNetworkTransportTaskCompletedDelegate: HTTPNetworkTransportD
4747

4848
// MARK: -
4949

50+
/// Methods which will be called if an error is receieved at the network level.
5051
public protocol HTTPNetworkTransportRetryDelegate: HTTPNetworkTransportDelegate {
5152

5253
/// Called when an error has been received after a request has been sent to the server to see if an operation should be retried or not.
@@ -65,12 +66,19 @@ public protocol HTTPNetworkTransportRetryDelegate: HTTPNetworkTransportDelegate
6566
retryHandler: @escaping (_ shouldRetry: Bool) -> Void)
6667
}
6768

68-
/// Methods which will be called after some kind of response has been received and it contains GraphQLErrors
69-
public protocol HTTPNetworkTransportGraphQLErrorDelegate: HTTPNetworkTransportDelegate {
69+
// MARK: -
7070

71+
/// Methods which will be called after some kind of response has been received and it contains GraphQLErrors.
72+
public protocol HTTPNetworkTransportGraphQLErrorDelegate: HTTPNetworkTransportDelegate {
7173

7274
/// Called when response contains one or more GraphQL errors.
73-
/// NOTE: Don't just call the `retryHandler` with `true` all the time, or you can potentially wind up in an infinite loop of errors
75+
///
76+
/// NOTE: The mere presence of a GraphQL error does not necessarily mean a request failed!
77+
/// GraphQL is design to allow partial success/failures to return, so make sure
78+
/// you're validating the *type* of error you're getting in this before deciding whether to retry or not.
79+
///
80+
/// ALSO NOTE: Don't just call the `retryHandler` with `true` all the time, or you can
81+
/// potentially wind up in an infinite loop of errors
7482
///
7583
/// - Parameters:
7684
/// - networkTransport: The network transport which received the error
@@ -79,7 +87,6 @@ public protocol HTTPNetworkTransportGraphQLErrorDelegate: HTTPNetworkTransportDe
7987
func networkTransport(_ networkTransport: HTTPNetworkTransport, receivedGraphQLErrors errors: [GraphQLError], retryHandler: @escaping (_ shouldRetry: Bool) -> Void)
8088
}
8189

82-
8390
// MARK: -
8491

8592
/// A network transport that uses HTTP POST requests to send GraphQL operations to a server, and that uses `URLSession` as the networking implementation.

0 commit comments

Comments
 (0)