Docs
Launch GraphOS Studio
You're viewing documentation for a previous version of this software. Switch to the latest stable version.


EXTENSION

ApolloClient

extension ApolloClient: ApolloClientProtocol

Properties

cacheKeyForObject

public var cacheKeyForObject: CacheKeyForObject?

Methods

clearCache(callbackQueue:completion:)

public func clearCache(callbackQueue: DispatchQueue = .main,
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:)

@discardableResult public func fetch<Query: GraphQLQuery>(query: Query,
cachePolicy: CachePolicy = .default,
contextIdentifier: UUID? = nil,
queue: DispatchQueue = .main,
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:)

public func watch<Query: GraphQLQuery>(query: Query,
cachePolicy: CachePolicy = .default,
callbackQueue: DispatchQueue = .main,
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:)

public func perform<Mutation: GraphQLMutation>(mutation: Mutation,
publishResultToStore: Bool = true,
queue: DispatchQueue = .main,
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:)

public func upload<Operation: GraphQLOperation>(operation: Operation,
files: [GraphQLFile],
queue: DispatchQueue = .main,
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:)

public func subscribe<Subscription: GraphQLSubscription>(subscription: Subscription,
queue: DispatchQueue = .main,
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.
Next
Introduction
Edit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy

Company