mirror of https://github.com/buster-so/buster.git
25 lines
705 B
TypeScript
25 lines
705 B
TypeScript
import { metricsQueryKeys } from '@/api/query_keys/metric';
|
|
import { upgradeMetricToIMetric } from '@/lib/metrics';
|
|
import { QueryClient } from '@tanstack/react-query';
|
|
import { getMetric_server } from './requests';
|
|
|
|
/*
|
|
|
|
*/
|
|
export const prefetchGetMetric = async (
|
|
params: Parameters<typeof getMetric_server>[0],
|
|
queryClientProp?: QueryClient
|
|
) => {
|
|
const queryClient = queryClientProp || new QueryClient();
|
|
|
|
await queryClient.prefetchQuery({
|
|
...metricsQueryKeys.metricsGetMetric(params.id, params.version_number || null),
|
|
queryFn: async () => {
|
|
const result = await getMetric_server(params);
|
|
return upgradeMetricToIMetric(result, null);
|
|
}
|
|
});
|
|
|
|
return queryClient;
|
|
};
|