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