66 isObject ,
77 Updater ,
88} from './utils'
9- import { defaultConfigRef , ReactQueryConfigRef } from './config'
9+ import { getDefaultedQueryConfig } from './config'
1010import { Query } from './query'
1111import {
1212 QueryConfig ,
@@ -76,7 +76,6 @@ export class QueryCache {
7676 isFetching : number
7777
7878 private config : QueryCacheConfig
79- private configRef : ReactQueryConfigRef
8079 private globalListeners : QueryCacheListener [ ]
8180
8281 constructor ( config ?: QueryCacheConfig ) {
@@ -85,25 +84,6 @@ export class QueryCache {
8584 // A frozen cache does not add new queries to the cache
8685 this . globalListeners = [ ]
8786
88- this . configRef = this . config . defaultConfig
89- ? {
90- current : {
91- shared : {
92- ...defaultConfigRef . current . shared ,
93- ...this . config . defaultConfig . shared ,
94- } ,
95- queries : {
96- ...defaultConfigRef . current . queries ,
97- ...this . config . defaultConfig . queries ,
98- } ,
99- mutations : {
100- ...defaultConfigRef . current . mutations ,
101- ...this . config . defaultConfig . mutations ,
102- } ,
103- } ,
104- }
105- : defaultConfigRef
106-
10787 this . queries = { }
10888 this . isFetching = 0
10989 }
@@ -118,7 +98,7 @@ export class QueryCache {
11898 }
11999
120100 getDefaultConfig ( ) {
121- return this . configRef . current
101+ return this . config . defaultConfig
122102 }
123103
124104 subscribe ( listener : QueryCacheListener ) : ( ) => void {
@@ -149,8 +129,8 @@ export class QueryCache {
149129 if ( typeof predicate === 'function' ) {
150130 predicateFn = predicate as QueryPredicateFn
151131 } else {
152- const [ queryHash , queryKey ] = this . configRef . current . queries !
153- . queryKeySerializerFn ! ( predicate )
132+ const config = getDefaultedQueryConfig ( this . config . defaultConfig )
133+ const [ queryHash , queryKey ] = config ! . queryKeySerializerFn ! ( predicate )
154134
155135 predicateFn = d =>
156136 options ?. exact
@@ -226,13 +206,13 @@ export class QueryCache {
226206
227207 buildQuery < TResult , TError = unknown > (
228208 userQueryKey : QueryKey ,
229- queryConfig : QueryConfig < TResult , TError > = { }
209+ queryConfig ? : QueryConfig < TResult , TError >
230210 ) : Query < TResult , TError > {
231- const config = {
232- ... this . configRef . current . shared ! ,
233- ... this . configRef . current . queries ! ,
234- ... queryConfig ,
235- } as QueryConfig < TResult , TError >
211+ const config = getDefaultedQueryConfig (
212+ this . getDefaultConfig ( ) ,
213+ undefined ,
214+ queryConfig
215+ )
236216
237217 const [ queryHash , queryKey ] = config . queryKeySerializerFn ! ( userQueryKey )
238218
@@ -386,7 +366,7 @@ export class QueryCache {
386366 setQueryData < TResult , TError = unknown > (
387367 queryKey : QueryKey ,
388368 updater : Updater < TResult | undefined , TResult > ,
389- config : QueryConfig < TResult , TError > = { }
369+ config ? : QueryConfig < TResult , TError >
390370 ) {
391371 let query = this . getQuery < TResult , TError > ( queryKey )
392372
0 commit comments