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