rewrite web request logging function

This commit is contained in:
pa
2026-03-10 23:33:15 +09:00
parent 1c9e4621f5
commit 0234abcca3
7 changed files with 83 additions and 39 deletions

View File

@@ -1,3 +1,4 @@
import { AppDebug, logWebRequest, withQueryLog } from '../services/appConfig';
import { queryClient } from './client';
import { queryKeys } from './keys';
import { toQueryOptions } from './policies';
@@ -151,10 +152,16 @@ export async function fetchWithEntityPolicy({ queryKey, policy, queryFn }) {
const data = await queryClient.fetchQuery({
queryKey,
queryFn,
queryFn: () => withQueryLog(queryFn),
...toQueryOptions(policy)
});
if (isFresh) {
logWebRequest('[QUERY CACHE HIT]', queryKey, data);
} else {
logWebRequest('[QUERY FETCH]', queryKey, data);
}
return {
data,
cache: isFresh