/** * Organizational chart edges defining parent-child reporting relationships between members within an entity * @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 { buildSelectionArgs } from '../selection'; import type { SelectionConfig } from '../selection'; import { orgChartEdgeKeys } from '../query-keys'; import type { OrgChartEdgeSelect, OrgChartEdgeWithRelations } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { OrgChartEdgeSelect, OrgChartEdgeWithRelations } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const orgChartEdgeQueryKey = orgChartEdgeKeys.detail; /** * Organizational chart edges defining parent-child reporting relationships between members within an entity * * @example * ```tsx * const { data, isLoading } = useOrgChartEdgeQuery({ * id: 'some-id', * selection: { fields: { id: true, name: true } }, * }); * ``` */ export function useOrgChartEdgeQuery< S extends OrgChartEdgeSelect, TData = { orgChartEdge: InferSelectResult | null; }, >( params: { id: string; selection: { fields: S; } & HookStrictSelect, OrgChartEdgeSelect>; } & Omit< UseQueryOptions< { orgChartEdge: InferSelectResult | null; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function useOrgChartEdgeQuery( params: { id: string; selection: SelectionConfig; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: orgChartEdgeKeys.detail(params.id), queryFn: () => getClient() .orgChartEdge.findOne({ id: params.id, select: args.select, }) .unwrap(), ...queryOptions, }); } /** * Organizational chart edges defining parent-child reporting relationships between members within an entity * * @example * ```ts * const data = await fetchOrgChartEdgeQuery({ * id: 'some-id', * selection: { fields: { id: true } }, * }); * ``` */ export async function fetchOrgChartEdgeQuery(params: { id: string; selection: { fields: S; } & HookStrictSelect, OrgChartEdgeSelect>; }): Promise<{ orgChartEdge: InferSelectResult | null; }>; export async function fetchOrgChartEdgeQuery(params: { id: string; selection: SelectionConfig; }): Promise { const args = buildSelectionArgs(params.selection); return getClient() .orgChartEdge.findOne({ id: params.id, select: args.select, }) .unwrap(); } /** * Organizational chart edges defining parent-child reporting relationships between members within an entity * * @example * ```ts * await prefetchOrgChartEdgeQuery(queryClient, { id: 'some-id', selection: { fields: { id: true } } }); * ``` */ export async function prefetchOrgChartEdgeQuery( queryClient: QueryClient, params: { id: string; selection: { fields: S; } & HookStrictSelect, OrgChartEdgeSelect>; } ): Promise; export async function prefetchOrgChartEdgeQuery( queryClient: QueryClient, params: { id: string; selection: SelectionConfig; } ): Promise { const args = buildSelectionArgs(params.selection); await queryClient.prefetchQuery({ queryKey: orgChartEdgeKeys.detail(params.id), queryFn: () => getClient() .orgChartEdge.findOne({ id: params.id, select: args.select, }) .unwrap(), }); }