ApolloClient


EXTENSION

ApolloClient

Swift
1extension ApolloClient: ApolloClientProtocol

Properties

cacheKeyForObject

Swift
1public var cacheKeyForObject: CacheKeyForObject?

Methods

clearCache(callbackQueue:completion:)

Swift
1public func clearCache(callbackQueue: DispatchQueue = .main,
2                       completion: ((Result<Void, Error>) -> Void)? = nil)

Parameters

NameDescription
callbackQueueThe queue to fall back on. Should default to the main queue.
completion[optional] A completion closure to execute when clearing has completed. Should default to nil.

fetch(query:cachePolicy:contextIdentifier:queue:resultHandler:)

Swift
1@discardableResult public func fetch<Query: GraphQLQuery>(query: Query,
2                                                          cachePolicy: CachePolicy = .default,
3                                                          contextIdentifier: UUID? = nil,
4                                                          queue: DispatchQueue = .main,
5                                                          resultHandler: GraphQLResultHandler<Query.Data>? = nil) -> Cancellable

Parameters

NameDescription
queryThe query to fetch.
cachePolicyA cache policy that specifies when results should be fetched from the server and when data should be loaded from the local cache.
queueA dispatch queue on which the result handler will be called. Should default to the main queue.
contextIdentifier[optional] A unique identifier for this request, to help with deduping cache hits for watchers. Should default to nil.
resultHandler[optional] A closure that is called when query results are available or when an error occurs.

watch(query:cachePolicy:callbackQueue:resultHandler:)

Swift
1public func watch<Query: GraphQLQuery>(query: Query,
2                                       cachePolicy: CachePolicy = .default,
3                                       callbackQueue: DispatchQueue = .main,
4                                       resultHandler: @escaping GraphQLResultHandler<Query.Data>) -> GraphQLQueryWatcher<Query>

Parameters

NameDescription
queryThe query to fetch.
cachePolicyA cache policy that specifies when results should be fetched from the server or from the local cache.
callbackQueueA dispatch queue on which the result handler will be called. Should default to the main queue.
resultHandler[optional] A closure that is called when query results are available or when an error occurs.

perform(mutation:publishResultToStore:queue:resultHandler:)

Swift
1public func perform<Mutation: GraphQLMutation>(mutation: Mutation,
2                                               publishResultToStore: Bool = true,
3                                               queue: DispatchQueue = .main,
4                                               resultHandler: GraphQLResultHandler<Mutation.Data>? = nil) -> Cancellable

Parameters

NameDescription
mutationThe mutation to perform.
publishResultToStoreIf true, this will publish the result returned from the operation to the cache store. Default is true.
queueA dispatch queue on which the result handler will be called. Should default to the main queue.
resultHandlerAn optional closure that is called when mutation results are available or when an error occurs.

upload(operation:files:queue:resultHandler:)

Swift
1public func upload<Operation: GraphQLOperation>(operation: Operation,
2                                                files: [GraphQLFile],
3                                                queue: DispatchQueue = .main,
4                                                resultHandler: GraphQLResultHandler<Operation.Data>? = nil) -> Cancellable

Parameters

NameDescription
operationThe operation to send
filesAn array of GraphQLFile objects to send.
queueA dispatch queue on which the result handler will be called. Should default to the main queue.
completionHandlerThe completion handler to execute when the request completes or errors. Note that an error will be returned If your networkTransport does not also conform to UploadingNetworkTransport.

subscribe(subscription:queue:resultHandler:)

Swift
1public func subscribe<Subscription: GraphQLSubscription>(subscription: Subscription,
2                                                         queue: DispatchQueue = .main,
3                                                         resultHandler: @escaping GraphQLResultHandler<Subscription.Data>) -> Cancellable

Parameters

NameDescription
subscriptionThe subscription to subscribe to.
fetchHTTPMethodThe HTTP Method to be used.
queueA dispatch queue on which the result handler will be called. Should default to the main queue.
resultHandlerAn optional closure that is called when mutation results are available or when an error occurs.
Feedback

Edit on GitHub

Forums