/** * Normalized repository events from local hooks and external providers * @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 { platformRepositoryEventKeys } from '../query-keys'; import type { PlatformRepositoryEventSelect, PlatformRepositoryEventWithRelations, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { PlatformRepositoryEventSelect, PlatformRepositoryEventWithRelations, } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const platformRepositoryEventQueryKey = platformRepositoryEventKeys.detail; /** * Normalized repository events from local hooks and external providers * * @example * ```tsx * const { data, isLoading } = usePlatformRepositoryEventQuery({ * id: 'some-id', * selection: { fields: { id: true, name: true } }, * }); * ``` */ export function usePlatformRepositoryEventQuery< S extends PlatformRepositoryEventSelect, TData = { platformRepositoryEvent: InferSelectResult | null; }, >( params: { id: string; selection: { fields: S; } & HookStrictSelect, PlatformRepositoryEventSelect>; } & Omit< UseQueryOptions< { platformRepositoryEvent: InferSelectResult | null; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function usePlatformRepositoryEventQuery( params: { id: string; selection: SelectionConfig; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: platformRepositoryEventKeys.detail(params.id), queryFn: () => getClient() .platformRepositoryEvent.findOne({ id: params.id, select: args.select, }) .unwrap(), ...queryOptions, }); } /** * Normalized repository events from local hooks and external providers * * @example * ```ts * const data = await fetchPlatformRepositoryEventQuery({ * id: 'some-id', * selection: { fields: { id: true } }, * }); * ``` */ export async function fetchPlatformRepositoryEventQuery< S extends PlatformRepositoryEventSelect, >(params: { id: string; selection: { fields: S; } & HookStrictSelect, PlatformRepositoryEventSelect>; }): Promise<{ platformRepositoryEvent: InferSelectResult | null; }>; export async function fetchPlatformRepositoryEventQuery(params: { id: string; selection: SelectionConfig; }): Promise { const args = buildSelectionArgs(params.selection); return getClient() .platformRepositoryEvent.findOne({ id: params.id, select: args.select, }) .unwrap(); } /** * Normalized repository events from local hooks and external providers * * @example * ```ts * await prefetchPlatformRepositoryEventQuery(queryClient, { id: 'some-id', selection: { fields: { id: true } } }); * ``` */ export async function prefetchPlatformRepositoryEventQuery( queryClient: QueryClient, params: { id: string; selection: { fields: S; } & HookStrictSelect, PlatformRepositoryEventSelect>; } ): Promise; export async function prefetchPlatformRepositoryEventQuery( queryClient: QueryClient, params: { id: string; selection: SelectionConfig; } ): Promise { const args = buildSelectionArgs(params.selection); await queryClient.prefetchQuery({ queryKey: platformRepositoryEventKeys.detail(params.id), queryFn: () => getClient() .platformRepositoryEvent.findOne({ id: params.id, select: args.select, }) .unwrap(), }); }