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,16 +98,16 @@ export class QueryCache {
11898 }
11999
120100 getDefaultConfig ( ) {
121- return this . configRef . current
101+ return this . config . defaultConfig
122102 }
123103
124- getDefaultedConfig < TResult , TError > ( config ?: QueryConfig < TResult , TError > ) {
125- return {
126- ...this . configRef . current . shared ! ,
127- ...this . configRef . current . queries ! ,
128- queryCache : this ,
104+ getDefaultedQueryConfig < TResult , TError > (
105+ config ?: QueryConfig < TResult , TError >
106+ ) : QueryConfig < TResult , TError > {
107+ return getDefaultedQueryConfig ( this . config . defaultConfig , undefined , {
129108 ...config ,
130- } as QueryConfig < TResult , TError >
109+ queryCache : this ,
110+ } )
131111 }
132112
133113 subscribe ( listener : QueryCacheListener ) : ( ) => void {
@@ -158,8 +138,8 @@ export class QueryCache {
158138 if ( typeof predicate === 'function' ) {
159139 predicateFn = predicate as QueryPredicateFn
160140 } else {
161- const [ queryHash , queryKey ] = this . configRef . current . queries !
162- . queryKeySerializerFn ! ( predicate )
141+ const config = this . getDefaultedQueryConfig ( )
142+ const [ queryHash , queryKey ] = config . queryKeySerializerFn ! ( predicate )
163143
164144 predicateFn = d =>
165145 options ?. exact
@@ -234,7 +214,7 @@ export class QueryCache {
234214 userQueryKey : QueryKey ,
235215 queryConfig ?: QueryConfig < TResult , TError >
236216 ) : Query < TResult , TError > {
237- const config = this . getDefaultedConfig ( queryConfig )
217+ const config = this . getDefaultedQueryConfig ( queryConfig )
238218
239219 const [ queryHash , queryKey ] = config . queryKeySerializerFn ! ( userQueryKey )
240220
0 commit comments