/** * Function invocation attempts — one row per worker attempt (including failed retries) with duration and error detail * @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 { functionInvocationAttemptKeys } from '../query-keys'; import type { FunctionInvocationAttemptSelect, FunctionInvocationAttemptWithRelations, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { FunctionInvocationAttemptSelect, FunctionInvocationAttemptWithRelations, } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const functionInvocationAttemptQueryKey = functionInvocationAttemptKeys.detail; /** * Function invocation attempts — one row per worker attempt (including failed retries) with duration and error detail * * @example * ```tsx * const { data, isLoading } = useFunctionInvocationAttemptQuery({ * id: 'some-id', * selection: { fields: { id: true, name: true } }, * }); * ``` */ export function useFunctionInvocationAttemptQuery< S extends FunctionInvocationAttemptSelect, TData = { functionInvocationAttempt: InferSelectResult | null; }, >( params: { id: string; selection: { fields: S; } & HookStrictSelect, FunctionInvocationAttemptSelect>; } & Omit< UseQueryOptions< { functionInvocationAttempt: InferSelectResult< FunctionInvocationAttemptWithRelations, S > | null; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function useFunctionInvocationAttemptQuery( params: { id: string; selection: SelectionConfig; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: functionInvocationAttemptKeys.detail(params.id), queryFn: () => getClient() .functionInvocationAttempt.findOne({ id: params.id, select: args.select, }) .unwrap(), ...queryOptions, }); } /** * Function invocation attempts — one row per worker attempt (including failed retries) with duration and error detail * * @example * ```ts * const data = await fetchFunctionInvocationAttemptQuery({ * id: 'some-id', * selection: { fields: { id: true } }, * }); * ``` */ export async function fetchFunctionInvocationAttemptQuery< S extends FunctionInvocationAttemptSelect, >(params: { id: string; selection: { fields: S; } & HookStrictSelect, FunctionInvocationAttemptSelect>; }): Promise<{ functionInvocationAttempt: InferSelectResult | null; }>; export async function fetchFunctionInvocationAttemptQuery(params: { id: string; selection: SelectionConfig; }): Promise { const args = buildSelectionArgs(params.selection); return getClient() .functionInvocationAttempt.findOne({ id: params.id, select: args.select, }) .unwrap(); } /** * Function invocation attempts — one row per worker attempt (including failed retries) with duration and error detail * * @example * ```ts * await prefetchFunctionInvocationAttemptQuery(queryClient, { id: 'some-id', selection: { fields: { id: true } } }); * ``` */ export async function prefetchFunctionInvocationAttemptQuery< S extends FunctionInvocationAttemptSelect, >( queryClient: QueryClient, params: { id: string; selection: { fields: S; } & HookStrictSelect, FunctionInvocationAttemptSelect>; } ): Promise; export async function prefetchFunctionInvocationAttemptQuery( queryClient: QueryClient, params: { id: string; selection: SelectionConfig; } ): Promise { const args = buildSelectionArgs(params.selection); await queryClient.prefetchQuery({ queryKey: functionInvocationAttemptKeys.detail(params.id), queryFn: () => getClient() .functionInvocationAttempt.findOne({ id: params.id, select: args.select, }) .unwrap(), }); }