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