From fc4e644c603c3ab391567c65f2fda795e895ad9d Mon Sep 17 00:00:00 2001 From: EskiMojo14 Date: Mon, 22 Jan 2024 23:37:51 +0000 Subject: [PATCH 1/8] build a patchQueriesData thunk to batch patching of endpoints --- packages/toolkit/package.json | 1 + packages/toolkit/src/query/core/buildSlice.ts | 91 ++++++++------ .../toolkit/src/query/core/buildThunks.ts | 117 +++++++++++++----- .../src/query/defaultSerializeQueryArgs.ts | 6 +- 4 files changed, 143 insertions(+), 72 deletions(-) diff --git a/packages/toolkit/package.json b/packages/toolkit/package.json index 34f89d2f23..8ae7c2e274 100644 --- a/packages/toolkit/package.json +++ b/packages/toolkit/package.json @@ -101,6 +101,7 @@ "format:check": "prettier --list-different \"(src|examples)/**/*.{ts,tsx}\" \"docs/*/**.md\"", "lint": "eslint src examples", "test": "vitest --run", + "test:watch": "vitest --watch", "type-tests": "yarn tsc -p src/tests/tsconfig.typetests.json && yarn tsc -p src/query/tests/tsconfig.typetests.json", "prepack": "yarn build" }, diff --git a/packages/toolkit/src/query/core/buildSlice.ts b/packages/toolkit/src/query/core/buildSlice.ts index bb712281a9..581ccd3d97 100644 --- a/packages/toolkit/src/query/core/buildSlice.ts +++ b/packages/toolkit/src/query/core/buildSlice.ts @@ -125,22 +125,28 @@ export function buildSlice({ }, prepare: prepareAutoBatched(), }, - queryResultPatched: { + queryResultsPatched: { reducer( draft, { - payload: { queryCacheKey, patches }, + payload, }: PayloadAction< - QuerySubstateIdentifier & { patches: readonly Patch[] } + Array > ) { - updateQuerySubstateIfExists(draft, queryCacheKey, (substate) => { - substate.data = applyPatches(substate.data as any, patches.concat()) - }) + for (const { queryCacheKey, patches } of payload) { + updateQuerySubstateIfExists(draft, queryCacheKey, (substate) => { + substate.data = applyPatches( + substate.data as any, + patches.concat() + ) + }) + } }, - prepare: prepareAutoBatched< - QuerySubstateIdentifier & { patches: readonly Patch[] } - >(), + prepare: + prepareAutoBatched< + Array + >(), }, }, extraReducers(builder) { @@ -328,39 +334,46 @@ export function buildSlice({ name: `${reducerPath}/invalidation`, initialState: initialState as InvalidationState, reducers: { - updateProvidedBy: { + updateProvidedBys: { reducer( draft, - action: PayloadAction<{ - queryCacheKey: QueryCacheKey - providedTags: readonly FullTagDescription[] - }> + action: PayloadAction< + Array<{ + queryCacheKey: QueryCacheKey + providedTags: readonly FullTagDescription[] + }> + > ) { - const { queryCacheKey, providedTags } = action.payload - - for (const tagTypeSubscriptions of Object.values(draft)) { - for (const idSubscriptions of Object.values(tagTypeSubscriptions)) { - const foundAt = idSubscriptions.indexOf(queryCacheKey) - if (foundAt !== -1) { - idSubscriptions.splice(foundAt, 1) + for (const { queryCacheKey, providedTags } of action.payload) { + for (const tagTypeSubscriptions of Object.values(draft)) { + for (const idSubscriptions of Object.values( + tagTypeSubscriptions + )) { + const foundAt = idSubscriptions.indexOf(queryCacheKey) + if (foundAt !== -1) { + idSubscriptions.splice(foundAt, 1) + } } } - } - for (const { type, id } of providedTags) { - const subscribedQueries = ((draft[type] ??= {})[ - id || '__internal_without_id' - ] ??= []) - const alreadySubscribed = subscribedQueries.includes(queryCacheKey) - if (!alreadySubscribed) { - subscribedQueries.push(queryCacheKey) + for (const { type, id } of providedTags) { + const subscribedQueries = ((draft[type] ??= {})[ + id || '__internal_without_id' + ] ??= []) + const alreadySubscribed = + subscribedQueries.includes(queryCacheKey) + if (!alreadySubscribed) { + subscribedQueries.push(queryCacheKey) + } } } }, - prepare: prepareAutoBatched<{ - queryCacheKey: QueryCacheKey - providedTags: readonly FullTagDescription[] - }>(), + prepare: prepareAutoBatched< + Array<{ + queryCacheKey: QueryCacheKey + providedTags: readonly FullTagDescription[] + }> + >(), }, }, extraReducers(builder) { @@ -408,12 +421,14 @@ export function buildSlice({ ) const { queryCacheKey } = action.meta.arg - invalidationSlice.caseReducers.updateProvidedBy( + invalidationSlice.caseReducers.updateProvidedBys( draft, - invalidationSlice.actions.updateProvidedBy({ - queryCacheKey, - providedTags, - }) + invalidationSlice.actions.updateProvidedBys([ + { + queryCacheKey, + providedTags, + }, + ]) ) } ) diff --git a/packages/toolkit/src/query/core/buildThunks.ts b/packages/toolkit/src/query/core/buildThunks.ts index 70627228c4..87293c6921 100644 --- a/packages/toolkit/src/query/core/buildThunks.ts +++ b/packages/toolkit/src/query/core/buildThunks.ts @@ -169,6 +169,20 @@ export type PatchQueryDataThunk< updateProvided?: boolean ) => ThunkAction +export type PatchQueriesDataThunk< + Definitions extends EndpointDefinitions, + PartialState +> = ( + patchesByEndpointName: { + [EndpointName in QueryKeys]?: Array<{ + args: QueryArgFrom + patches: readonly Patch[] + updateProvided?: boolean + }> + }, + defaultUpdateProvided?: boolean +) => ThunkAction + export type UpdateQueryDataThunk< Definitions extends EndpointDefinitions, PartialState @@ -236,43 +250,88 @@ export function buildThunks< }) { type State = RootState - const patchQueryData: PatchQueryDataThunk = - (endpointName, args, patches, updateProvided) => (dispatch, getState) => { - const endpointDefinition = endpointDefinitions[endpointName] - - const queryCacheKey = serializeQueryArgs({ - queryArgs: args, - endpointDefinition, - endpointName, - }) + const patchQueriesData: PatchQueriesDataThunk = + (patchesByEndpointName, defaultUpdateProvided) => (dispatch, getState) => { + const queryResultPatches: Parameters< + typeof api.internalActions.queryResultsPatched + >[0] = [] + + const arrayified = Object.entries< + | { + args: any + patches: readonly Patch[] + updateProvided?: boolean | undefined + }[] + | undefined + >(patchesByEndpointName) + for (const [endpointName, patches] of arrayified) { + if (!patches) continue + for (const { args, patches: endpointPatches } of patches) { + const endpointDefinition = endpointDefinitions[endpointName] + + const queryCacheKey = serializeQueryArgs({ + queryArgs: args, + endpointDefinition, + endpointName, + }) - dispatch( - api.internalActions.queryResultPatched({ queryCacheKey, patches }) - ) + queryResultPatches.push({ queryCacheKey, patches: endpointPatches }) + } + } - if (!updateProvided) { - return + if (queryResultPatches.length) { + dispatch(api.internalActions.queryResultsPatched(queryResultPatches)) } - const newValue = api.endpoints[endpointName].select(args)( - // Work around TS 4.1 mismatch - getState() as RootState - ) + // now that the state is updated, we can update the tags - const providedTags = calculateProvidedBy( - endpointDefinition.providesTags, - newValue.data, - undefined, - args, - {}, - assertTagType - ) + const providedPatches: Parameters< + typeof api.internalActions.updateProvidedBys + >[0] = [] - dispatch( - api.internalActions.updateProvidedBy({ queryCacheKey, providedTags }) - ) + for (const [endpointName, patches] of arrayified) { + if (!patches) continue + for (const { args, updateProvided } of patches) { + if (!(updateProvided ?? defaultUpdateProvided)) { + continue + } + const endpointDefinition = endpointDefinitions[endpointName] + + const queryCacheKey = serializeQueryArgs({ + queryArgs: args, + endpointDefinition, + endpointName, + }) + + const newValue = api.endpoints[endpointName].select(args)( + // Work around TS 4.1 mismatch + getState() as RootState + ) + + const providedTags = calculateProvidedBy( + endpointDefinition.providesTags, + newValue.data, + undefined, + args, + {}, + assertTagType + ) + + providedPatches.push({ queryCacheKey, providedTags }) + } + } + if (providedPatches.length) { + dispatch(api.internalActions.updateProvidedBys(providedPatches)) + } } + const patchQueryData: PatchQueryDataThunk = ( + endpointName, + args, + patches, + updateProvided + ) => patchQueriesData({ [endpointName]: [{ args, patches, updateProvided }] }) + const updateQueryData: UpdateQueryDataThunk = (endpointName, args, updateRecipe, updateProvided = true) => (dispatch, getState) => { diff --git a/packages/toolkit/src/query/defaultSerializeQueryArgs.ts b/packages/toolkit/src/query/defaultSerializeQueryArgs.ts index e3fe011b44..53aca09b5d 100644 --- a/packages/toolkit/src/query/defaultSerializeQueryArgs.ts +++ b/packages/toolkit/src/query/defaultSerializeQueryArgs.ts @@ -42,8 +42,4 @@ export type SerializeQueryArgs = (_: { endpointName: string }) => ReturnType -export type InternalSerializeQueryArgs = (_: { - queryArgs: any - endpointDefinition: EndpointDefinition - endpointName: string -}) => QueryCacheKey +export type InternalSerializeQueryArgs = SerializeQueryArgs From 57ae20f5b4c24e3395051f04bf7ef43b4c42a5b1 Mon Sep 17 00:00:00 2001 From: EskiMojo14 Date: Mon, 22 Jan 2024 23:40:09 +0000 Subject: [PATCH 2/8] golf --- packages/toolkit/src/query/core/buildThunks.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/toolkit/src/query/core/buildThunks.ts b/packages/toolkit/src/query/core/buildThunks.ts index 87293c6921..842c311726 100644 --- a/packages/toolkit/src/query/core/buildThunks.ts +++ b/packages/toolkit/src/query/core/buildThunks.ts @@ -260,7 +260,7 @@ export function buildThunks< | { args: any patches: readonly Patch[] - updateProvided?: boolean | undefined + updateProvided?: boolean }[] | undefined >(patchesByEndpointName) From 470b9e1071cba3426112a84287e7814a8c3589d7 Mon Sep 17 00:00:00 2001 From: EskiMojo14 Date: Mon, 22 Jan 2024 23:45:04 +0000 Subject: [PATCH 3/8] expose in util --- packages/toolkit/src/query/core/buildThunks.ts | 1 + packages/toolkit/src/query/core/module.ts | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/packages/toolkit/src/query/core/buildThunks.ts b/packages/toolkit/src/query/core/buildThunks.ts index 842c311726..6aafbe957a 100644 --- a/packages/toolkit/src/query/core/buildThunks.ts +++ b/packages/toolkit/src/query/core/buildThunks.ts @@ -714,6 +714,7 @@ In the case of an unhandled error, no tags will be "provided" or "invalidated".` updateQueryData, upsertQueryData, patchQueryData, + patchQueriesData, buildMatchThunkActions, } } diff --git a/packages/toolkit/src/query/core/module.ts b/packages/toolkit/src/query/core/module.ts index 8d8ab6b117..26f681f02f 100644 --- a/packages/toolkit/src/query/core/module.ts +++ b/packages/toolkit/src/query/core/module.ts @@ -3,6 +3,7 @@ */ import type { PatchQueryDataThunk, + PatchQueriesDataThunk, UpdateQueryDataThunk, UpsertQueryDataThunk, } from './buildThunks' @@ -303,6 +304,11 @@ declare module '../apiTypes' { RootState > + patchQueriesData: PatchQueriesDataThunk< + Definitions, + RootState + > + /** * A Redux action creator that can be dispatched to manually reset the api state completely. This will immediately remove all existing cache entries, and all queries will be considered 'uninitialized'. * @@ -500,6 +506,7 @@ export const coreModule = ({ queryThunk, mutationThunk, patchQueryData, + patchQueriesData, updateQueryData, upsertQueryData, prefetch, @@ -531,6 +538,7 @@ export const coreModule = ({ safeAssign(api.util, { patchQueryData, + patchQueriesData, updateQueryData, upsertQueryData, prefetch, From aec9c7a02d402943bc3b48b56800bef6953d8c12 Mon Sep 17 00:00:00 2001 From: EskiMojo14 Date: Tue, 23 Jan 2024 00:50:49 +0000 Subject: [PATCH 4/8] add updateQueriesData thunk --- .../toolkit/src/query/core/buildThunks.ts | 191 +++++++++++++----- packages/toolkit/src/query/core/module.ts | 8 + 2 files changed, 153 insertions(+), 46 deletions(-) diff --git a/packages/toolkit/src/query/core/buildThunks.ts b/packages/toolkit/src/query/core/buildThunks.ts index 6aafbe957a..45a1bf5664 100644 --- a/packages/toolkit/src/query/core/buildThunks.ts +++ b/packages/toolkit/src/query/core/buildThunks.ts @@ -5,7 +5,12 @@ import type { BaseQueryError, QueryReturnValue, } from '../baseQueryTypes' -import type { RootState, QueryKeys, QuerySubstateIdentifier } from './apiState' +import type { + RootState, + QueryKeys, + QuerySubstateIdentifier, + QueryCacheKey, +} from './apiState' import { QueryStatus } from './apiState' import type { StartQueryActionCreatorOptions, @@ -46,6 +51,7 @@ import { HandledError } from '../HandledError' import type { ApiEndpointQuery, PrefetchOptions } from './module' import type { UnwrapPromise } from '../tsHelpers' +import { emplace } from '../../utils' declare module './module' { export interface ApiEndpointQuery< @@ -193,6 +199,35 @@ export type UpdateQueryDataThunk< updateProvided?: boolean ) => ThunkAction +type PatchCollectionArray = { + [I in keyof InputArray]: PatchCollection +} + +export type UpdateQueriesDataThunk< + Definitions extends EndpointDefinitions, + PartialState +> = < + EndpointMap extends { + [EndpointName in QueryKeys]?: Array<{ + args: QueryArgFrom + updateRecipe: Recipe> + updateProvided?: boolean + }> + } +>( + recipesByEndpointName: EndpointMap, + defaultUpdateProvided?: boolean +) => ThunkAction< + { + [EndpointName in keyof EndpointMap]: EndpointMap[EndpointName] extends any[] + ? PatchCollectionArray + : never + }, + PartialState, + any, + UnknownAction +> + export type UpsertQueryDataThunk< Definitions extends EndpointDefinitions, PartialState @@ -291,8 +326,11 @@ export function buildThunks< for (const [endpointName, patches] of arrayified) { if (!patches) continue - for (const { args, updateProvided } of patches) { - if (!(updateProvided ?? defaultUpdateProvided)) { + for (const { + args, + updateProvided = defaultUpdateProvided, + } of patches) { + if (!updateProvided) { continue } const endpointDefinition = endpointDefinitions[endpointName] @@ -332,60 +370,120 @@ export function buildThunks< updateProvided ) => patchQueriesData({ [endpointName]: [{ args, patches, updateProvided }] }) - const updateQueryData: UpdateQueryDataThunk = - (endpointName, args, updateRecipe, updateProvided = true) => - (dispatch, getState) => { - const endpointDefinition = api.endpoints[endpointName] + const updateQueriesData: UpdateQueriesDataThunk = + (recipesByEndpointName, defaultUpdateProvided) => (dispatch, getState) => { + const ret: Record> = {} + const patchesByEndpointName: Parameters< + typeof api.util.patchQueriesData + >[0] = {} + const stateCache = new Map() + const arrayified = Object.entries< + | { + args: any + updateRecipe: Recipe + updateProvided?: boolean + }[] + | undefined + >(recipesByEndpointName) + for (const [endpointName, recipes] of arrayified) { + if (!recipes) continue + for (const [ + idx, + { args, updateRecipe, updateProvided = defaultUpdateProvided }, + ] of recipes.entries()) { + const endpointDefinition = endpointDefinitions[endpointName] + const endpoint = api.endpoints[endpointName] - const currentState = endpointDefinition.select(args)( - // Work around TS 4.1 mismatch - getState() as RootState - ) + const queryCacheKey = serializeQueryArgs({ + queryArgs: args, + endpointDefinition, + endpointName, + }) - let ret: PatchCollection = { - patches: [], - inversePatches: [], - undo: () => - dispatch( - api.util.patchQueryData( - endpointName, - args, - ret.inversePatches, - updateProvided - ) - ), - } - if (currentState.status === QueryStatus.uninitialized) { - return ret - } - let newValue - if ('data' in currentState) { - if (isDraftable(currentState.data)) { - const [value, patches, inversePatches] = produceWithPatches( - currentState.data, - updateRecipe - ) - ret.patches.push(...patches) - ret.inversePatches.push(...inversePatches) - newValue = value - } else { - newValue = updateRecipe(currentState.data) - ret.patches.push({ op: 'replace', path: [], value: newValue }) - ret.inversePatches.push({ - op: 'replace', - path: [], - value: currentState.data, + const currentState: ReturnType> = + emplace(stateCache, queryCacheKey, { + insert: () => + endpoint.select(args)( + // Work around TS 4.1 mismatch + getState() as RootState + ), + }) + + let patchCollection: PatchCollection = { + patches: [], + inversePatches: [], + undo: () => + dispatch( + api.util.patchQueryData( + endpointName as QueryKeys, + args, + patchCollection.inversePatches, + updateProvided + ) + ), + } + + if (currentState.status === QueryStatus.uninitialized) { + ;(ret[endpointName] ??= [])[idx] = patchCollection + continue + } + + let newValue: any + if ('data' in currentState) { + if (isDraftable(currentState.data)) { + const [value, patches, inversePatches] = produceWithPatches( + currentState.data, + updateRecipe + ) + patchCollection.patches.push(...patches) + patchCollection.inversePatches.push(...inversePatches) + newValue = value + } else { + newValue = updateRecipe(currentState.data) + patchCollection.patches.push({ + op: 'replace', + path: [], + value: newValue, + }) + patchCollection.inversePatches.push({ + op: 'replace', + path: [], + value: currentState.data, + }) + } + // update the state cache with the new value, so that any following recipes will see the updated value + emplace(stateCache, queryCacheKey, { + update: (v) => ({ ...v, data: newValue }), + }) + } + + ;(ret[endpointName] ??= [])[idx] = patchCollection + ;(patchesByEndpointName[ + endpointName as keyof typeof patchesByEndpointName + ] ??= []).push({ + args, + patches: patchCollection.patches, + updateProvided, }) } } dispatch( - api.util.patchQueryData(endpointName, args, ret.patches, updateProvided) + api.util.patchQueriesData(patchesByEndpointName, defaultUpdateProvided) ) - return ret + return ret as any } + const updateQueryData: UpdateQueryDataThunk = + (endpointName, args, updateRecipe, updateProvided = true) => + (dispatch, getState) => + dispatch( + updateQueriesData({ + [endpointName]: [{ args, updateRecipe, updateProvided }], + }) + )[endpointName][0] + const upsertQueryData: UpsertQueryDataThunk = (endpointName, args, value) => (dispatch) => { return dispatch( @@ -712,6 +810,7 @@ In the case of an unhandled error, no tags will be "provided" or "invalidated".` mutationThunk, prefetch, updateQueryData, + updateQueriesData, upsertQueryData, patchQueryData, patchQueriesData, diff --git a/packages/toolkit/src/query/core/module.ts b/packages/toolkit/src/query/core/module.ts index 26f681f02f..d40d863242 100644 --- a/packages/toolkit/src/query/core/module.ts +++ b/packages/toolkit/src/query/core/module.ts @@ -6,6 +6,7 @@ import type { PatchQueriesDataThunk, UpdateQueryDataThunk, UpsertQueryDataThunk, + UpdateQueriesDataThunk, } from './buildThunks' import { buildThunks } from './buildThunks' import type { @@ -250,6 +251,11 @@ declare module '../apiTypes' { RootState > + updateQueriesData: UpdateQueriesDataThunk< + Definitions, + RootState + > + /** * A Redux thunk action creator that, when dispatched, acts as an artificial API request to upsert a value into the cache. * @@ -508,6 +514,7 @@ export const coreModule = ({ patchQueryData, patchQueriesData, updateQueryData, + updateQueriesData, upsertQueryData, prefetch, buildMatchThunkActions, @@ -540,6 +547,7 @@ export const coreModule = ({ patchQueryData, patchQueriesData, updateQueryData, + updateQueriesData, upsertQueryData, prefetch, resetApiState: sliceActions.resetApiState, From d9c4da1ee1cb36ec31886310596bbb15d8d3ae41 Mon Sep 17 00:00:00 2001 From: EskiMojo14 Date: Tue, 23 Jan 2024 01:00:54 +0000 Subject: [PATCH 5/8] simplify logic --- packages/toolkit/src/query/core/buildThunks.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/toolkit/src/query/core/buildThunks.ts b/packages/toolkit/src/query/core/buildThunks.ts index 45a1bf5664..78de7025a7 100644 --- a/packages/toolkit/src/query/core/buildThunks.ts +++ b/packages/toolkit/src/query/core/buildThunks.ts @@ -387,6 +387,10 @@ export function buildThunks< >(recipesByEndpointName) for (const [endpointName, recipes] of arrayified) { if (!recipes) continue + const endpointPatches = (patchesByEndpointName[ + endpointName as keyof typeof patchesByEndpointName + ] ??= []) + const endpointCollections = (ret[endpointName] ??= []) for (const [ idx, { args, updateRecipe, updateProvided = defaultUpdateProvided }, @@ -457,10 +461,8 @@ export function buildThunks< }) } - ;(ret[endpointName] ??= [])[idx] = patchCollection - ;(patchesByEndpointName[ - endpointName as keyof typeof patchesByEndpointName - ] ??= []).push({ + endpointCollections[idx] = patchCollection + endpointPatches.push({ args, patches: patchCollection.patches, updateProvided, From 59a273deaed97a8f4c024e5b8e11d10b9c7eaab4 Mon Sep 17 00:00:00 2001 From: EskiMojo14 Date: Tue, 23 Jan 2024 01:02:12 +0000 Subject: [PATCH 6/8] missed one --- packages/toolkit/src/query/core/buildThunks.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/toolkit/src/query/core/buildThunks.ts b/packages/toolkit/src/query/core/buildThunks.ts index 78de7025a7..aec21b7473 100644 --- a/packages/toolkit/src/query/core/buildThunks.ts +++ b/packages/toolkit/src/query/core/buildThunks.ts @@ -428,7 +428,7 @@ export function buildThunks< } if (currentState.status === QueryStatus.uninitialized) { - ;(ret[endpointName] ??= [])[idx] = patchCollection + endpointCollections[idx] = patchCollection continue } From 70538150621fc25ccc1316521cec796428c07a20 Mon Sep 17 00:00:00 2001 From: Ben Durrant Date: Tue, 23 Jan 2024 10:38:58 +0000 Subject: [PATCH 7/8] avoid never[] type --- packages/toolkit/src/query/core/buildThunks.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/toolkit/src/query/core/buildThunks.ts b/packages/toolkit/src/query/core/buildThunks.ts index aec21b7473..0effdc63c8 100644 --- a/packages/toolkit/src/query/core/buildThunks.ts +++ b/packages/toolkit/src/query/core/buildThunks.ts @@ -374,7 +374,7 @@ export function buildThunks< (recipesByEndpointName, defaultUpdateProvided) => (dispatch, getState) => { const ret: Record> = {} const patchesByEndpointName: Parameters< - typeof api.util.patchQueriesData + PatchQueriesDataThunk >[0] = {} const stateCache = new Map() const arrayified = Object.entries< @@ -387,9 +387,12 @@ export function buildThunks< >(recipesByEndpointName) for (const [endpointName, recipes] of arrayified) { if (!recipes) continue - const endpointPatches = (patchesByEndpointName[ - endpointName as keyof typeof patchesByEndpointName - ] ??= []) + const endpointPatches: Array<{ + args: any + patches: readonly Patch[] + updateProvided?: boolean + }> = (patchesByEndpointName[endpointName as QueryKeys] ??= + []) const endpointCollections = (ret[endpointName] ??= []) for (const [ idx, From 8be87122bad474b26f00fa8afd6f95660b37b4f5 Mon Sep 17 00:00:00 2001 From: Ben Durrant Date: Wed, 24 Jan 2024 16:02:49 +0000 Subject: [PATCH 8/8] match updateQueryData default for updateProvided --- packages/toolkit/src/query/core/buildThunks.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/toolkit/src/query/core/buildThunks.ts b/packages/toolkit/src/query/core/buildThunks.ts index 0effdc63c8..174ed15799 100644 --- a/packages/toolkit/src/query/core/buildThunks.ts +++ b/packages/toolkit/src/query/core/buildThunks.ts @@ -371,7 +371,8 @@ export function buildThunks< ) => patchQueriesData({ [endpointName]: [{ args, patches, updateProvided }] }) const updateQueriesData: UpdateQueriesDataThunk = - (recipesByEndpointName, defaultUpdateProvided) => (dispatch, getState) => { + (recipesByEndpointName, defaultUpdateProvided = true) => + (dispatch, getState) => { const ret: Record> = {} const patchesByEndpointName: Parameters< PatchQueriesDataThunk