/** * Bindings from a repository event to the flow graph that should run * @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 { repositoryWorkflowKeys } from '../query-keys'; import type { RepositoryWorkflowSelect, RepositoryWorkflowWithRelations, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { RepositoryWorkflowSelect, RepositoryWorkflowWithRelations, } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const repositoryWorkflowQueryKey = repositoryWorkflowKeys.detail; /** * Bindings from a repository event to the flow graph that should run * * @example * ```tsx * const { data, isLoading } = useRepositoryWorkflowQuery({ * id: 'some-id', * selection: { fields: { id: true, name: true } }, * }); * ``` */ export function useRepositoryWorkflowQuery< S extends RepositoryWorkflowSelect, TData = { repositoryWorkflow: InferSelectResult | null; }, >( params: { id: string; selection: { fields: S; } & HookStrictSelect, RepositoryWorkflowSelect>; } & Omit< UseQueryOptions< { repositoryWorkflow: InferSelectResult | null; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function useRepositoryWorkflowQuery( params: { id: string; selection: SelectionConfig; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: repositoryWorkflowKeys.detail(params.id), queryFn: () => getClient() .repositoryWorkflow.findOne({ id: params.id, select: args.select, }) .unwrap(), ...queryOptions, }); } /** * Bindings from a repository event to the flow graph that should run * * @example * ```ts * const data = await fetchRepositoryWorkflowQuery({ * id: 'some-id', * selection: { fields: { id: true } }, * }); * ``` */ export async function fetchRepositoryWorkflowQuery(params: { id: string; selection: { fields: S; } & HookStrictSelect, RepositoryWorkflowSelect>; }): Promise<{ repositoryWorkflow: InferSelectResult | null; }>; export async function fetchRepositoryWorkflowQuery(params: { id: string; selection: SelectionConfig; }): Promise { const args = buildSelectionArgs(params.selection); return getClient() .repositoryWorkflow.findOne({ id: params.id, select: args.select, }) .unwrap(); } /** * Bindings from a repository event to the flow graph that should run * * @example * ```ts * await prefetchRepositoryWorkflowQuery(queryClient, { id: 'some-id', selection: { fields: { id: true } } }); * ``` */ export async function prefetchRepositoryWorkflowQuery( queryClient: QueryClient, params: { id: string; selection: { fields: S; } & HookStrictSelect, RepositoryWorkflowSelect>; } ): Promise; export async function prefetchRepositoryWorkflowQuery( queryClient: QueryClient, params: { id: string; selection: SelectionConfig; } ): Promise { const args = buildSelectionArgs(params.selection); await queryClient.prefetchQuery({ queryKey: repositoryWorkflowKeys.detail(params.id), queryFn: () => getClient() .repositoryWorkflow.findOne({ id: params.id, select: args.select, }) .unwrap(), }); }