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