Skip to content

API Documentation / @pinia/colada

@pinia/colada

Pinia Colada

Interfaces

InterfaceDescription
_EntryFilter_Key-
_EntryFilter_NoKey-
DataState_Error-
DataState_Pending-
DataState_Success-
PiniaColadaOptionsOptions for the Pinia Colada plugin.
PiniaColadaPluginA Pinia Colada plugin.
PiniaColadaPluginContextContext passed to a Pinia Colada plugin.
PiniaColadaQueryHooksPluginOptionsOptions for PiniaColadaQueryHooksPlugin.
TypesConfigAllows you to extend the default types of the library.
UseInfiniteQueryOptionsOptions for useInfiniteQuery.
UseInfiniteQueryReturn-
UseMutationOptionsOptions to create a mutation.
UseMutationOptionsGlobalOptions for mutations that can be globally overridden.
UseMutationReturn-
UseQueryEntryA query entry in the cache.
UseQueryEntryExtensionsAllows defining extensions to the query entry that are returned by useQuery().
UseQueryOptionsOptions for useQuery(). Can be extended by plugins.
UseQueryOptionsGlobalOptions for queries that can be globally overridden.
UseQueryReturnReturn type of useQuery().

Type Aliases

Type AliasDescription
_EntryFilter-
AsyncStatusThe status of an async operation tied to pinia colada e.g. queries and mutations. - idle: not loading - loading: currently loading
DataStatePossible states for data based on its status.
DataStateStatusThe status of data. - pending: initial state - error: has an error - success: has data
EntryKeyKey used to identify a query or a mutation. Must be a JSON serializable value. Type is unknwon to avoid deep type recursion.
EntryKeyTaggedSame as EntryKey but with a data tag that allows inference of the data type. Used by defineQueryOptions().
QueryCacheThe cache of the queries. It's the store returned by useQueryCache.
RefetchOnControlPossible values for refetchOnMount, refetchOnWindowFocus, and refetchOnReconnect. true refetches if data is stale (calles refresh()), false never refetches, 'always' always refetches.
UseQueryEntryFilterFilter object to get entries from the query cache.
UseQueryOptionsWithDefaults-

Variables

VariableDescription
PiniaColadaPlugin that installs the Query and Mutation plugins alongside some extra plugins.
useQueryCacheComposable to get the cache of the queries. As any other composable, it can be used inside the setup function of a component, within another composable, or in injectable contexts like stores and navigation guards.

Functions

FunctionDescription
defineMutationDefine a mutation with the given options. Similar to useMutation(options) but allows you to reuse the mutation in multiple places.
defineQueryDefine a query with the given options. Similar to useQuery(options) but allows you to reuse all of the query state in multiple places. It only allow static values in options. If you need dynamic values, use the function version.
defineQueryOptionsDefine type-safe query options. Can be static or dynamic. Define the arguments based on what's needed on the query and the key. Use an object if you need multiple properties.
hydrateQueryCacheHydrates the query cache with the serialized cache. Used during SSR.
PiniaColadaQueryHooksPluginAllows to add global hooks to all queries: - onSuccess: called when a query is successful - onError: called when a query throws an error - onSettled: called when a query is settled (either successfully or with an error)
serializeQueryCacheSerializes the query cache to a compressed version. Used during SSR.
toCacheKeySerializes the given key (query or mutation key) to a string.
useInfiniteQueryStore and merge paginated data into a single cache entry. Allows to handle infinite scrolling. This is an experimental API and is subject to change.
useMutationSetups a mutation.
useQueryEnsures and return a shared query state based on the key option.

Released under the MIT License.