26 lines
745 B
TypeScript
26 lines
745 B
TypeScript
import { getUser } from '@/api/user/query';
|
|
import { STALE_TIME } from '@/constants/request';
|
|
import type { ProcessContext } from '@/process/types';
|
|
import { useStore } from '@/stores/hooks';
|
|
import { trpcPureClient } from '@/trpc/client';
|
|
import { useApolloClient } from '@apollo/client';
|
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
|
|
export function useProcessContext(): ProcessContext {
|
|
const store = useStore();
|
|
const apolloClient = useApolloClient();
|
|
const queryClient = useQueryClient();
|
|
|
|
const { data: user } = useQuery(['user'], ({ signal }) => getUser({ signal }), {
|
|
staleTime: STALE_TIME,
|
|
});
|
|
|
|
return {
|
|
apolloClient,
|
|
queryClient,
|
|
store,
|
|
trpcClient: trpcPureClient,
|
|
user,
|
|
};
|
|
}
|