@@ -16,7 +16,11 @@ import {
1616 ChartConfigWithDateRange ,
1717 ChartConfigWithOptDateRange ,
1818} from '@hyperdx/common-utils/dist/types' ;
19- import { useQuery , UseQueryOptions } from '@tanstack/react-query' ;
19+ import {
20+ useQuery ,
21+ useQueryClient ,
22+ UseQueryOptions ,
23+ } from '@tanstack/react-query' ;
2024
2125import {
2226 convertDateRangeToGranularityString ,
@@ -195,6 +199,7 @@ export function useQueriedChartConfig(
195199 AdditionalUseQueriedChartConfigOptions ,
196200) {
197201 const clickhouseClient = useClickhouseClient ( ) ;
202+ const queryClient = useQueryClient ( ) ;
198203
199204 const query = useQuery < TQueryFnData , ClickHouseQueryError | Error > ( {
200205 // Include disableQueryChunking in the query key to ensure that queries with the
@@ -203,7 +208,7 @@ export function useQueriedChartConfig(
203208 // TODO: Replace this with `streamedQuery` when it is no longer experimental. Use 'replace' refetch mode.
204209 // https://tanstack.com/query/latest/docs/reference/streamedQuery
205210 queryFn : async context => {
206- const query = context . client
211+ const query = queryClient
207212 . getQueryCache ( )
208213 . find ( { queryKey : context . queryKey , exact : true } ) ;
209214 const isRefetch = ! ! query && query . state . data !== undefined ;
@@ -232,21 +237,21 @@ export function useQueriedChartConfig(
232237
233238 // When refetching, the cache is not updated until all chunks are fetched.
234239 if ( ! isRefetch ) {
235- context . client . setQueryData < TQueryFnData > (
240+ queryClient . setQueryData < TQueryFnData > (
236241 context . queryKey ,
237242 accumulatedChunks ,
238243 ) ;
239244 }
240245 }
241246
242247 if ( isRefetch && ! context . signal . aborted ) {
243- context . client . setQueryData < TQueryFnData > (
248+ queryClient . setQueryData < TQueryFnData > (
244249 context . queryKey ,
245250 accumulatedChunks ,
246251 ) ;
247252 }
248253
249- return context . client . getQueryData ( context . queryKey ) ! ;
254+ return queryClient . getQueryData ( context . queryKey ) ! ;
250255 } ,
251256 retry : 1 ,
252257 refetchOnWindowFocus : false ,
0 commit comments