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
Name | Description |
---|---|
callbackQueue | The 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
Name | Description |
---|---|
query | The query to fetch. |
cachePolicy | A cache policy that specifies when results should be fetched from the server and when data should be loaded from the local cache. |
queue | A 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
Name | Description |
---|---|
query | The query to fetch. |
cachePolicy | A cache policy that specifies when results should be fetched from the server or from the local cache. |
callbackQueue | A 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
Name | Description |
---|---|
mutation | The mutation to perform. |
publishResultToStore | If true , this will publish the result returned from the operation to the cache store. Default is true . |
queue | A dispatch queue on which the result handler will be called. Should default to the main queue. |
resultHandler | An 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
Name | Description |
---|---|
operation | The operation to send |
files | An array of GraphQLFile objects to send. |
queue | A dispatch queue on which the result handler will be called. Should default to the main queue. |
completionHandler | The 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
Name | Description |
---|---|
subscription | The subscription to subscribe to. |
fetchHTTPMethod | The HTTP Method to be used. |
queue | A dispatch queue on which the result handler will be called. Should default to the main queue. |
resultHandler | An optional closure that is called when mutation results are available or when an error occurs. |