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