@@ -9,7 +9,6 @@ const cache: WeakMap<any, string> | undefined = WeakMap
9
9
export const defaultSerializeQueryArgs : SerializeQueryArgs < any > = ( {
10
10
endpointName,
11
11
queryArgs,
12
- replacer,
13
12
} ) => {
14
13
let serialized = ''
15
14
@@ -19,8 +18,8 @@ export const defaultSerializeQueryArgs: SerializeQueryArgs<any> = ({
19
18
serialized = cached
20
19
} else {
21
20
const stringified = JSON . stringify ( queryArgs , ( key , value ) => {
22
- // Use custom replacer first before applying key-sorting behavior:
23
- value = replacer ? replacer ( key , value ) : value
21
+ // Handle bigints
22
+ value = typeof value === 'bigint' ? { $bigint : value . toString ( ) } : value
24
23
// Sort the object keys before stringifying, to prevent useQuery({ a: 1, b: 2 }) having a different cache key than useQuery({ b: 2, a: 1 })
25
24
value = isPlainObject ( value )
26
25
? Object . keys ( value )
@@ -44,14 +43,10 @@ export type SerializeQueryArgs<QueryArgs, ReturnType = string> = (_: {
44
43
queryArgs : QueryArgs
45
44
endpointDefinition : EndpointDefinition < any , any , any , any >
46
45
endpointName : string
47
- // Allows for a custom stringify replacer while keeping key-sorting behavior. e.g. for serializing bigint.
48
- replacer ?: ( key : string , value : any ) => { }
49
46
} ) => ReturnType
50
47
51
48
export type InternalSerializeQueryArgs = ( _ : {
52
49
queryArgs : any
53
50
endpointDefinition : EndpointDefinition < any , any , any , any >
54
51
endpointName : string
55
- // Allows for a custom stringify replacer while keeping key-sorting behavior. e.g. for serializing bigint.
56
- replacer ?: ( key : string , value : any ) => { }
57
52
} ) => QueryCacheKey
0 commit comments