Skip to content

Commit

Permalink
feat(query-cache)!: Rename setQueryState to setEntryState
Browse files Browse the repository at this point in the history
BREAKING CHANGE: To better match the arguments, the `setQueryState`
action has been renamed to `setEntryState`.
  • Loading branch information
posva committed Aug 26, 2024
1 parent 4d42d01 commit f481eb0
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/query-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export const useQueryCache = defineStore(QUERY_STORE_ID, ({ action }) => {
.options!.query({ signal })
.then((data) => {
if (pendingCall === entry.pending && !signal.aborted) {
setQueryState(entry, {
setEntryState(entry, {
data,
error: null,
status: 'success',
Expand All @@ -460,7 +460,7 @@ export const useQueryCache = defineStore(QUERY_STORE_ID, ({ action }) => {
&& error
&& (error.name !== 'AbortError' || error === signal.reason)
) {
setQueryState(entry, {
setEntryState(entry, {
data: entry.state.value.data,
error,
status: 'error',
Expand Down Expand Up @@ -497,7 +497,7 @@ export const useQueryCache = defineStore(QUERY_STORE_ID, ({ action }) => {
* Sets the state of a query entry in the cache. This action is called every time the cache state changes and can be
* used by plugins to detect changes.
*/
const setQueryState = action(
const setEntryState = action(
<TResult, TError>(
entry: UseQueryEntry<TResult, TError>,
state: DataState<TResult, TError>,
Expand All @@ -522,8 +522,7 @@ export const useQueryCache = defineStore(QUERY_STORE_ID, ({ action }) => {
// FIXME: it should create the entry if it doesn't exist
if (!entry) return

// FIXME: rename to setEntryState
setQueryState(entry, {
setEntryState(entry, {
// if we don't cast, this is not technically correct
// the user is responsible for setting the data
...(entry.state.value as DataState_Success<TResult>),
Expand Down Expand Up @@ -563,7 +562,6 @@ export const useQueryCache = defineStore(QUERY_STORE_ID, ({ action }) => {
// : undefined,

ensureDefinedQuery,
setQueryState,
setQueryData,
getQueryData,
cancelQuery,
Expand All @@ -576,6 +574,7 @@ export const useQueryCache = defineStore(QUERY_STORE_ID, ({ action }) => {
refresh,
ensure,
remove,
setEntryState,
getEntries,
}
})
Expand Down

0 comments on commit f481eb0

Please sign in to comment.