@@ -9,7 +9,6 @@ const cache: WeakMap<any, string> | undefined = WeakMap
99export const defaultSerializeQueryArgs : SerializeQueryArgs < any > = ( {
1010 endpointName,
1111 queryArgs,
12- replacer,
1312} ) => {
1413 let serialized = ''
1514
@@ -19,8 +18,8 @@ export const defaultSerializeQueryArgs: SerializeQueryArgs<any> = ({
1918 serialized = cached
2019 } else {
2120 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
2423 // Sort the object keys before stringifying, to prevent useQuery({ a: 1, b: 2 }) having a different cache key than useQuery({ b: 2, a: 1 })
2524 value = isPlainObject ( value )
2625 ? Object . keys ( value )
@@ -44,14 +43,10 @@ export type SerializeQueryArgs<QueryArgs, ReturnType = string> = (_: {
4443 queryArgs : QueryArgs
4544 endpointDefinition : EndpointDefinition < any , any , any , any >
4645 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 ) => { }
4946} ) => ReturnType
5047
5148export type InternalSerializeQueryArgs = ( _ : {
5249 queryArgs : any
5350 endpointDefinition : EndpointDefinition < any , any , any , any >
5451 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 ) => { }
5752} ) => QueryCacheKey
0 commit comments