@pinia/colada
Advanced tools
Changelog
0.12.0 (2024-11-06)
transformError
was never fully implemented so they are being removed and might come back if they is a real-word use case for themdelayLoadingRef
util, use the @pinia/colada-plugin-delay
instead.Error
to defaultError
allows to differentiate the property from the existing global Error class. Upgrading should be straightforward.Changelog
0.11.0 (2024-10-25)
useQueryCache()
outside. It could be added back if needed but it's
more pragmatic to start without it.queryCache.cancelQuery()
is renamed to
queryCache.cancel()
to better match the other functions naming. A new
function queryCache.cancelQueries()
is added to actually cancel one or
multiple queries instead of just one.cache
is renamed to queryCache
for
consistency.queryCache
is the result
of useQueryCache()
.Changelog
0.10.0 (2024-10-04)
useMutation()
hooks now uses positional arguments. This change is mainly to simplify migration from TanStack Query.caches.invalidateQueries()
only fetches active querieskeys
option that automatically invalidate keys
has been renamed to invalidateKeys
and moved to a plugin. This is in
practice not needed. It's just an opinionated convenience that can be
replaced by directly invalidating queries in the cache with the
onSettled()
hook in useMutation()
:const { mutate } = useMutation({
onSettled({ caches, vars: { id } }) {
caches.invalidateQueries({ key: ['contacts-search'] })
caches.invalidateQueries({ key: ['contacts', id] })
},
mutation: (contact) => patchContact(contact),
})
Changelog
0.8.0 (2024-08-12)
isFetching
from useQuery()
is renamed to
isLoading
to better reflect that it's connected to asyncStatus
.
The setup option in useQuery now receives the options
as the second argument instead of a context object with the query return
value and the options. This allows the setup function to have a more
predictable signature and makes it easier to type. Only PiniaColada
has this option, it has been removed from useQuery. Overall, the
option still needs more thinking and will probably change in the future
again.
plugins: The onSuccess
, onError
, and onSettled
global
hooks have been moved from PiniaPlugin
to a Pinia Colada plugin:
PiniaColadaQueryHooksPlugin
app.use(PiniaColada, {
+ plugins: [
+ PiniaColadaQueryHooksPlugin({
onSuccess() {},
onError() {},
onSettled() {},
+ }),
+ ],
})
This feature splits up the status
state into two
different status properties:
status
is now just for the data 'pending' | 'success' | 'error'
queryStatus
tells if the query is still running or not with 'idle' | 'running'
refetch
, refresh
and similar methods now resolve
the state
property without rejecting. This is usually more convenient.QueryStatus
type has been split into
DataStateStatus
and OperationStateStatus
.Their arguments have changed as well.
QueryPlugin
. Use
PiniaColada
instead.state
property to useQuery
for type narrowing (22f3e21)active
property to query entry (994db63), closes #65