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