You are viewing documentation for a previous version of this software.

Switch to the latest stable version.

RequestChain


CLASS

RequestChain

Swift
1public class RequestChain: Cancellable

A chain that allows a single network request to be created and executed.

Properties

isNotCancelled

Swift
1public var isNotCancelled: Bool

Checks the underlying value of isCancelled. Set up like this for better readability in guard statements

additionalErrorHandler

Swift
1public var additionalErrorHandler: ApolloErrorInterceptor?

Something which allows additional error handling to occur when some kind of error has happened.

Methods

init(interceptors:callbackQueue:)

Swift
1public init(interceptors: [ApolloInterceptor],
2            callbackQueue: DispatchQueue = .main)

Creates a chain with the given interceptor array.

  • Parameters:

    • interceptors: The array of interceptors to use.

    • callbackQueue: The DispatchQueue to call back on when an error or result occurs. Defaults to .main.

Parameters

NameDescription
interceptorsThe array of interceptors to use.
callbackQueueThe DispatchQueue to call back on when an error or result occurs. Defaults to .main.

kickoff(request:completion:)

Swift
1public func kickoff<Operation: GraphQLOperation>(
2  request: HTTPRequest<Operation>,
3  completion: @escaping (Result<GraphQLResult<Operation.Data>, Error>) -> Void)

Kicks off the request from the beginning of the interceptor array.

  • Parameters:

    • request: The request to send.

    • completion: The completion closure to call when the request has completed.

Parameters

NameDescription
requestThe request to send.
completionThe completion closure to call when the request has completed.

proceedAsync(request:response:completion:)

Swift
1public func proceedAsync<Operation: GraphQLOperation>(
2  request: HTTPRequest<Operation>,
3  response: HTTPResponse<Operation>?,
4  completion: @escaping (Result<GraphQLResult<Operation.Data>, Error>) -> Void)

Proceeds to the next interceptor in the array.

  • Parameters:

    • request: The in-progress request object

    • response: [optional] The in-progress response object, if received yet

    • completion: The completion closure to call when data has been processed and should be returned to the UI.

Parameters

NameDescription
requestThe in-progress request object
response[optional] The in-progress response object, if received yet
completionThe completion closure to call when data has been processed and should be returned to the UI.

cancel()

Swift
1public func cancel()

Cancels the entire chain of interceptors.

retry(request:completion:)

Swift
1public func retry<Operation: GraphQLOperation>(
2  request: HTTPRequest<Operation>,
3  completion: @escaping (Result<GraphQLResult<Operation.Data>, Error>) -> Void)

Restarts the request starting from the first interceptor.

  • Parameters:

    • request: The request to retry

    • completion: The completion closure to call when the request has completed.

Parameters

NameDescription
requestThe request to retry
completionThe completion closure to call when the request has completed.

handleErrorAsync(_:request:response:completion:)

Swift
1public func handleErrorAsync<Operation: GraphQLOperation>(
2  _ error: Error,
3  request: HTTPRequest<Operation>,
4  response: HTTPResponse<Operation>?,
5  completion: @escaping (Result<GraphQLResult<Operation.Data>, Error>) -> Void)

Handles the error by returning it on the appropriate queue, or by applying an additional error interceptor if one has been provided.

  • Parameters:

    • error: The error to handle

    • request: The request, as far as it has been constructed.

    • response: The response, as far as it has been constructed.

    • completion: The completion closure to call when work is complete.

Parameters

NameDescription
errorThe error to handle
requestThe request, as far as it has been constructed.
responseThe response, as far as it has been constructed.
completionThe completion closure to call when work is complete.

returnValueAsync(for:value:completion:)

Swift
1public func returnValueAsync<Operation: GraphQLOperation>(
2  for request: HTTPRequest<Operation>,
3  value: GraphQLResult<Operation.Data>,
4  completion: @escaping (Result<GraphQLResult<Operation.Data>, Error>) -> Void)

Handles a resulting value by returning it on the appropriate queue.

  • Parameters:

    • request: The request, as far as it has been constructed.

    • value: The value to be returned

    • completion: The completion closure to call when work is complete.

Parameters

NameDescription
requestThe request, as far as it has been constructed.
valueThe value to be returned
completionThe completion closure to call when work is complete.
Feedback

Edit on GitHub

Forums