QueryClient class final

Owns query and mutation caches for one app or one server request.

Constructors

QueryClient({QueryClientOptions options = const QueryClientOptions(), QueryCache? queryCache, MutationCache? mutationCache, QueryFocusManager? focusManager, QueryOnlineManager? onlineManager, QueryScheduler? scheduler})
Creates a client with optionally supplied runtime components.

Properties

focusManager → QueryFocusManager
Application focus signal.
final
hashCode → int
The hash code for this object.
no setterinherited
mutationCache → MutationCache
Storage for mutation executions.
final
onlineManager → QueryOnlineManager
Network connectivity signal.
final
options → QueryClientOptions
Shared client options.
final
queryCache → QueryCache
Storage for query state machines.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scheduler → QueryScheduler
Clock and timer implementation.
final

Methods

cancelQueries([QueryFilter filter = const QueryFilter(), bool silent = false, bool revert = true]) → Future<void>
Cancels active fetches matching filter.
clear() → void
Removes all query and mutation cache entries.
ensureQueryData<T>(QueryOptions<T> options, {bool revalidateIfStale = false}) → Future<T>
Returns cached data or fetches it when absent.
executeMutation<TData, TVariables, TOptimistic>(MutationOptions<TData, TVariables, TOptimistic> options, TVariables variables) → Future<TData>
Executes one mutation immediately.
fetchQuery<T>(QueryOptions<T> options) → Future<T>
Returns fresh cached data or fetches it.
findAll([QueryFilter filter = const QueryFilter()]) → Iterable<Query>
Returns cached queries matching filter.
getMutationDefaults(QueryKey<Object?> key) → MutationOptions?
Returns mutation defaults registered for key.
getQueryData<T>(QueryKey<T> key) → T?
Returns cached data for key, if present.
getQueryDefaults(QueryKey<Object?> key) → QueryPolicy
Resolves client and prefix defaults for key.
getQueryState<T>(QueryKey<T> key) → QueryState<T>?
Returns cached state for key, if present.
invalidateQueries([QueryFilter filter = const QueryFilter(), bool refetchActive = true]) → Future<void>
Invalidates matching queries and optionally refetches active ones.
isFetching([QueryFilter filter = const QueryFilter()]) → int
Counts matching queries that are currently fetching.
mount() → void
Connects cache behavior to focus and connectivity signals.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
observe<T>(QueryOptions<T> options) → QueryObserver<T>
Creates an observer for options.
observeMutation<TData, TVariables, TOptimistic>(MutationOptions<TData, TVariables, TOptimistic> options) → MutationObserver<TData, TVariables, TOptimistic>
Creates an observer for a mutation definition.
prefetchQuery<T>(QueryOptions<T> options) → Future<void>
Fetches options while reporting errors only through cache state.
query<T>(QueryOptions<T> options) → Query<T>
Returns or creates the cache entry for options.
refetchQueries([QueryFilter filter = const QueryFilter()]) → Future<void>
Refetches enabled, non-static queries matching filter.
removeQueries([QueryFilter filter = const QueryFilter()]) → void
Removes queries matching filter from the cache.
resetQueries([QueryFilter filter = const QueryFilter()]) → Future<void>
Restores matching queries to initial state and refetches active ones.
resolve<T>(QueryOptions<T> value) → ResolvedQueryOptions<T>
Resolves every runtime option for value.
restoreQuery<T>(QueryKey<T> key, QueryState<T> state, {Map<String, Object?> meta = const <String, Object?>{}}) → Query<T>
Restores a query before its executable QueryOptions are registered.
resumePausedMutations() → Future<void>
Continues mutations paused by connectivity or serial scopes.
setMutationDefaults<TData, TVariables, TOptimistic>(QueryKey<Object?> key, MutationOptions<TData, TVariables, TOptimistic> options) → void
Registers executable defaults for mutations with key.
setQueryData<T>(QueryKey<T> key, T update(T? previous), {DateTime? updatedAt}) → T
Updates data for an already registered query.
setQueryDefaults(QueryKey<Object?> prefix, QueryPolicy policy) → void
Registers a policy inherited by keys beginning with prefix.
toString() → String
A string representation of this object.
inherited
unmount() → void
Disconnects one mounted consumer from runtime signals.

Operators

operator ==(Object other) → bool
The equality operator.
inherited