/** * List query hook for MachineModule * @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 { buildListSelectionArgs } from '../selection'; import type { ListSelectionConfig } from '../selection'; import { machineModuleKeys } from '../query-keys'; import type { MachineModuleSelect, MachineModuleWithRelations, MachineModuleFilter, MachineModuleOrderBy, } from '../../orm/input-types'; import type { FindManyArgs, InferSelectResult, ConnectionResult, HookStrictSelect, } from '../../orm/select-types'; export type { MachineModuleSelect, MachineModuleWithRelations, MachineModuleFilter, MachineModuleOrderBy, } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const machineModulesQueryKey = machineModuleKeys.list; /** * Query hook for fetching MachineModule list * * @example * ```tsx * const { data, isLoading } = useMachineModulesQuery({ * selection: { * fields: { id: true, name: true }, * where: { name: { equalTo: "example" } }, * orderBy: ['CREATED_AT_DESC'], * first: 10, * }, * }); * ``` */ export function useMachineModulesQuery< S extends MachineModuleSelect, TData = { machineModules: ConnectionResult>; }, >( params: { selection: { fields: S; } & Omit, 'fields'> & HookStrictSelect, MachineModuleSelect>; } & Omit< UseQueryOptions< { machineModules: ConnectionResult>; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function useMachineModulesQuery( params: { selection: ListSelectionConfig; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildListSelectionArgs< MachineModuleSelect, MachineModuleFilter, MachineModuleOrderBy >(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: machineModuleKeys.list(args), queryFn: () => getClient().machineModule.findMany(args).unwrap(), ...queryOptions, }); } /** * Fetch MachineModule list without React hooks * * @example * ```ts * const data = await fetchMachineModulesQuery({ * selection: { * fields: { id: true }, * first: 10, * }, * }); * ``` */ export async function fetchMachineModulesQuery(params: { selection: { fields: S; } & Omit, 'fields'> & HookStrictSelect, MachineModuleSelect>; }): Promise<{ machineModules: ConnectionResult>; }>; export async function fetchMachineModulesQuery(params: { selection: ListSelectionConfig; }) { const args = buildListSelectionArgs< MachineModuleSelect, MachineModuleFilter, MachineModuleOrderBy >(params.selection); return getClient().machineModule.findMany(args).unwrap(); } /** * Prefetch MachineModule list for SSR or cache warming * * @example * ```ts * await prefetchMachineModulesQuery(queryClient, { selection: { fields: { id: true }, first: 10 } }); * ``` */ export async function prefetchMachineModulesQuery( queryClient: QueryClient, params: { selection: { fields: S; } & Omit, 'fields'> & HookStrictSelect, MachineModuleSelect>; } ): Promise; export async function prefetchMachineModulesQuery( queryClient: QueryClient, params: { selection: ListSelectionConfig; } ): Promise { const args = buildListSelectionArgs< MachineModuleSelect, MachineModuleFilter, MachineModuleOrderBy >(params.selection); await queryClient.prefetchQuery({ queryKey: machineModuleKeys.list(args), queryFn: () => getClient().machineModule.findMany(args).unwrap(), }); }