/** * Single item query hook for ComputeLogModule * @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 { computeLogModuleKeys } from '../query-keys'; import type { ComputeLogModuleSelect, ComputeLogModuleWithRelations } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { ComputeLogModuleSelect, ComputeLogModuleWithRelations } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const computeLogModuleQueryKey = computeLogModuleKeys.detail; /** * Query hook for fetching a single ComputeLogModule * * @example * ```tsx * const { data, isLoading } = useComputeLogModuleQuery({ * id: 'some-id', * selection: { fields: { id: true, name: true } }, * }); * ``` */ export function useComputeLogModuleQuery< S extends ComputeLogModuleSelect, TData = { computeLogModule: InferSelectResult | null; }, >( params: { id: string; selection: { fields: S; } & HookStrictSelect, ComputeLogModuleSelect>; } & Omit< UseQueryOptions< { computeLogModule: InferSelectResult | null; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function useComputeLogModuleQuery( params: { id: string; selection: SelectionConfig; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: computeLogModuleKeys.detail(params.id), queryFn: () => getClient() .computeLogModule.findOne({ id: params.id, select: args.select, }) .unwrap(), ...queryOptions, }); } /** * Fetch a single ComputeLogModule without React hooks * * @example * ```ts * const data = await fetchComputeLogModuleQuery({ * id: 'some-id', * selection: { fields: { id: true } }, * }); * ``` */ export async function fetchComputeLogModuleQuery(params: { id: string; selection: { fields: S; } & HookStrictSelect, ComputeLogModuleSelect>; }): Promise<{ computeLogModule: InferSelectResult | null; }>; export async function fetchComputeLogModuleQuery(params: { id: string; selection: SelectionConfig; }): Promise { const args = buildSelectionArgs(params.selection); return getClient() .computeLogModule.findOne({ id: params.id, select: args.select, }) .unwrap(); } /** * Prefetch a single ComputeLogModule for SSR or cache warming * * @example * ```ts * await prefetchComputeLogModuleQuery(queryClient, { id: 'some-id', selection: { fields: { id: true } } }); * ``` */ export async function prefetchComputeLogModuleQuery( queryClient: QueryClient, params: { id: string; selection: { fields: S; } & HookStrictSelect, ComputeLogModuleSelect>; } ): Promise; export async function prefetchComputeLogModuleQuery( queryClient: QueryClient, params: { id: string; selection: SelectionConfig; } ): Promise { const args = buildSelectionArgs(params.selection); await queryClient.prefetchQuery({ queryKey: computeLogModuleKeys.detail(params.id), queryFn: () => getClient() .computeLogModule.findOne({ id: params.id, select: args.select, }) .unwrap(), }); }