-
Notifications
You must be signed in to change notification settings - Fork 749
Expand file tree
/
Copy pathApolloInterceptor.swift
More file actions
27 lines (24 loc) · 1.09 KB
/
ApolloInterceptor.swift
File metadata and controls
27 lines (24 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#if !COCOAPODS
import ApolloMigrationAPI
#endif
/// A protocol to set up a chainable unit of networking work.
public protocol ApolloInterceptor {
/// Used to uniquely identify this interceptor from other interceptors in a request chain.
///
/// Each operation request has it's own interceptor request chain so the interceptors do not
/// need to be uniquely identifiable between each and every request, only unique between the
/// list of interceptors in a single request.
var id: String { get }
/// Called when this interceptor should do its work.
///
/// - Parameters:
/// - chain: The chain the interceptor is a part of.
/// - request: The request, as far as it has been constructed
/// - response: [optional] The response, if received
/// - completion: The completion block to fire when data needs to be returned to the UI.
func interceptAsync<Operation: GraphQLOperation>(
chain: any RequestChain,
request: HTTPRequest<Operation>,
response: HTTPResponse<Operation>?,
completion: @escaping (Result<GraphQLResult<Operation.Data>, any Error>) -> Void)
}