/** * Custom query hook for currentUserId * @generated by @constructive-io/graphql-codegen * DO NOT EDIT - changes will be overwritten */ import { useQuery } from '@tanstack/react-query'; import type { UseQueryOptions, UseQueryResult, QueryClient } from '@tanstack/react-query'; import { getClient } from '../client'; import { buildSelectionArgs } from '../selection'; import type { SelectionConfig } from '../selection'; import { customQueryKeys } from '../query-keys'; /** Query key factory - re-exported from query-keys.ts */ export const currentUserIdQueryKey = customQueryKeys.currentUserId; /** * Query hook for currentUserId * * @example * ```tsx * const { data, isLoading } = useCurrentUserIdQuery(); * * if (data?.currentUserId) { * console.log(data.currentUserId); * } * ``` */ export function useCurrentUserIdQuery< TData = { currentUserId: string | null; }, >( params?: Omit< UseQueryOptions< { currentUserId: string | null; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function useCurrentUserIdQuery< TData = { currentUserId: string | null; }, >( params?: Omit< UseQueryOptions< { currentUserId: string | null; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult { const queryOptions = params ?? {}; return useQuery({ queryKey: currentUserIdQueryKey(), queryFn: () => getClient().query.currentUserId().unwrap(), ...queryOptions, }); } /** * Fetch currentUserId without React hooks * * @example * ```ts * const data = await fetchCurrentUserIdQuery(); * ``` */ export async function fetchCurrentUserIdQuery() { return getClient().query.currentUserId().unwrap(); } /** * Prefetch currentUserId for SSR or cache warming * * @example * ```ts * await prefetchCurrentUserIdQuery(queryClient); * ``` */ export async function prefetchCurrentUserIdQuery(queryClient: QueryClient): Promise { await queryClient.prefetchQuery({ queryKey: currentUserIdQueryKey(), queryFn: () => getClient().query.currentUserId().unwrap(), }); }