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