@tanstack/query-core 5.0.0-alpha.12 → 5.0.0-alpha.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/query-core",
3
- "version": "5.0.0-alpha.12",
3
+ "version": "5.0.0-alpha.18",
4
4
  "description": "The framework agnostic core that powers TanStack Query",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -139,11 +139,11 @@ export class MutationCache extends Subscribable<MutationCacheListener> {
139
139
  >(
140
140
  filters: MutationFilters,
141
141
  ): Mutation<TData, TError, TVariables, TContext> | undefined {
142
- if (typeof filters.exact === 'undefined') {
143
- filters.exact = true
144
- }
142
+ const defaultedFilters = { exact: true, ...filters }
145
143
 
146
- return this.#mutations.find((mutation) => matchMutation(filters, mutation))
144
+ return this.#mutations.find((mutation) =>
145
+ matchMutation(defaultedFilters, mutation),
146
+ )
147
147
  }
148
148
 
149
149
  findAll(filters: MutationFilters = {}): Mutation[] {
package/src/queryCache.ts CHANGED
@@ -176,13 +176,11 @@ export class QueryCache extends Subscribable<QueryCacheListener> {
176
176
  find<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData>(
177
177
  filters: WithRequired<QueryFilters, 'queryKey'>,
178
178
  ): Query<TQueryFnData, TError, TData> | undefined {
179
- if (typeof filters.exact === 'undefined') {
180
- filters.exact = true
181
- }
179
+ const defaultedFilters = { exact: true, ...filters }
182
180
 
183
- return this.getAll().find((query) => matchQuery(filters, query)) as
184
- | Query<TQueryFnData, TError, TData>
185
- | undefined
181
+ return this.getAll().find((query) =>
182
+ matchQuery(defaultedFilters, query),
183
+ ) as Query<TQueryFnData, TError, TData> | undefined
186
184
  }
187
185
 
188
186
  findAll(filters: QueryFilters = {}): Query[] {
@@ -212,14 +212,12 @@ export class QueryClient {
212
212
  filters: QueryFilters = {},
213
213
  cancelOptions: CancelOptions = {},
214
214
  ): Promise<void> {
215
- if (typeof cancelOptions.revert === 'undefined') {
216
- cancelOptions.revert = true
217
- }
215
+ const defaultedCancelOptions = { revert: true, ...cancelOptions }
218
216
 
219
217
  const promises = notifyManager.batch(() =>
220
218
  this.#queryCache
221
219
  .findAll(filters)
222
- .map((query) => query.cancel(cancelOptions)),
220
+ .map((query) => query.cancel(defaultedCancelOptions)),
223
221
  )
224
222
 
225
223
  return Promise.all(promises).then(noop).catch(noop)