MCPcopy Create free account
hub / github.com/TanStack/query / invalidateQueries

Method invalidateQueries

packages/vue-query/src/queryClient.ts:209–241  ·  view source on GitHub ↗
(
    filters:
      | MaybeRefDeep<InvalidateQueryFilters<TTaggedQueryKey>>
      | (() => InvalidateQueryFilters<TTaggedQueryKey>) = {},
    options: MaybeRefDeep<InvalidateOptions> | (() => InvalidateOptions) = {},
  )

Source from the content-addressed store, hash-verified

207 options?: MaybeRefDeep<InvalidateOptions>,
208 ): Promise<void>
209 invalidateQueries<TTaggedQueryKey extends QueryKey = QueryKey>(
210 filters:
211 | MaybeRefDeep<InvalidateQueryFilters<TTaggedQueryKey>>
212 | (() => InvalidateQueryFilters<TTaggedQueryKey>) = {},
213 options: MaybeRefDeep<InvalidateOptions> | (() => InvalidateOptions) = {},
214 ): Promise<void> {
215 const filtersCloned = cloneDeepUnref(
216 filters as MaybeRefDeep<InvalidateQueryFilters<TTaggedQueryKey>>,
217 )
218 const optionsCloned = cloneDeepUnref(
219 options as MaybeRefDeep<InvalidateOptions>,
220 )
221
222 super.invalidateQueries(
223 { ...filtersCloned, refetchType: 'none' },
224 optionsCloned,
225 )
226
227 if (filtersCloned.refetchType === 'none') {
228 return Promise.resolve()
229 }
230
231 const refetchFilters: RefetchQueryFilters<TTaggedQueryKey> = {
232 ...filtersCloned,
233 type: filtersCloned.refetchType ?? filtersCloned.type ?? 'active',
234 }
235
236 // (dosipiuk): We need to delay `refetchQueries` execution to next macro task for all reactive values to be updated.
237 // This ensures that `context` in `queryFn` while `invalidating` along reactive variable change has correct
238 return nextTick().then(() => {
239 return super.refetchQueries(refetchFilters, optionsCloned)
240 })
241 }
242
243 refetchQueries<
244 TQueryFnData = unknown,

Callers 15

setupDevtoolsFunction · 0.45
PageFunction · 0.45
PageFunction · 0.45
PageFunction · 0.45
PageFunction · 0.45
PageFunction · 0.45

Calls 2

cloneDeepUnrefFunction · 0.90
refetchQueriesMethod · 0.45

Tested by 7

PageFunction · 0.36
PageFunction · 0.36
PageFunction · 0.36
PageFunction · 0.36
PageFunction · 0.36
PageFunction · 0.36
OuterFunction · 0.36