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,15 @@ 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 ! ,
104+ getDefaultedQueryConfig < TResult , TError > (
105+ config ?: QueryConfig < TResult , TError >
106+ ) : QueryConfig < TResult , TError > {
107+ return getDefaultedQueryConfig ( this . getDefaultConfig ( ) , undefined , config , {
128108 queryCache : this ,
129- ...config ,
130- } as QueryConfig < TResult , TError >
109+ } )
131110 }
132111
133112 subscribe ( listener : QueryCacheListener ) : ( ) => void {
@@ -158,8 +137,8 @@ export class QueryCache {
158137 if ( typeof predicate === 'function' ) {
159138 predicateFn = predicate as QueryPredicateFn
160139 } else {
161- const [ queryHash , queryKey ] = this . configRef . current . queries !
162- . queryKeySerializerFn ! ( predicate )
140+ const config = this . getDefaultedQueryConfig ( )
141+ const [ queryHash , queryKey ] = config . queryKeySerializerFn ! ( predicate )
163142
164143 predicateFn = d =>
165144 options ?. exact
@@ -234,7 +213,7 @@ export class QueryCache {
234213 userQueryKey : QueryKey ,
235214 queryConfig ?: QueryConfig < TResult , TError >
236215 ) : Query < TResult , TError > {
237- const config = this . getDefaultedConfig ( queryConfig )
216+ const config = this . getDefaultedQueryConfig ( queryConfig )
238217
239218 const [ queryHash , queryKey ] = config . queryKeySerializerFn ! ( userQueryKey )
240219
@@ -352,6 +331,7 @@ export class QueryCache {
352331 TError ,
353332 PrefetchQueryOptions | undefined
354333 > ( args )
334+
355335 // https://github.com/tannerlinsley/react-query/issues/652
356336 const configWithoutRetry = { retry : false , ...config }
357337
0 commit comments