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