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