/** * Flow graph definitions — FBP graphs stored in the dedicated graph Merkle store * @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 { functionGraphKeys } from '../query-keys'; import type { FunctionGraphSelect, FunctionGraphWithRelations } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { FunctionGraphSelect, FunctionGraphWithRelations } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const functionGraphQueryKey = functionGraphKeys.detail; /** * Flow graph definitions — FBP graphs stored in the dedicated graph Merkle store * * @example * ```tsx * const { data, isLoading } = useFunctionGraphQuery({ * id: 'some-id', * selection: { fields: { id: true, name: true } }, * }); * ``` */ export function useFunctionGraphQuery< S extends FunctionGraphSelect, TData = { functionGraph: InferSelectResult | null; }, >( params: { id: string; selection: { fields: S; } & HookStrictSelect, FunctionGraphSelect>; } & Omit< UseQueryOptions< { functionGraph: InferSelectResult | null; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function useFunctionGraphQuery( params: { id: string; selection: SelectionConfig; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: functionGraphKeys.detail(params.id), queryFn: () => getClient() .functionGraph.findOne({ id: params.id, select: args.select, }) .unwrap(), ...queryOptions, }); } /** * Flow graph definitions — FBP graphs stored in the dedicated graph Merkle store * * @example * ```ts * const data = await fetchFunctionGraphQuery({ * id: 'some-id', * selection: { fields: { id: true } }, * }); * ``` */ export async function fetchFunctionGraphQuery(params: { id: string; selection: { fields: S; } & HookStrictSelect, FunctionGraphSelect>; }): Promise<{ functionGraph: InferSelectResult | null; }>; export async function fetchFunctionGraphQuery(params: { id: string; selection: SelectionConfig; }): Promise { const args = buildSelectionArgs(params.selection); return getClient() .functionGraph.findOne({ id: params.id, select: args.select, }) .unwrap(); } /** * Flow graph definitions — FBP graphs stored in the dedicated graph Merkle store * * @example * ```ts * await prefetchFunctionGraphQuery(queryClient, { id: 'some-id', selection: { fields: { id: true } } }); * ``` */ export async function prefetchFunctionGraphQuery( queryClient: QueryClient, params: { id: string; selection: { fields: S; } & HookStrictSelect, FunctionGraphSelect>; } ): Promise; export async function prefetchFunctionGraphQuery( queryClient: QueryClient, params: { id: string; selection: SelectionConfig; } ): Promise { const args = buildSelectionArgs(params.selection); await queryClient.prefetchQuery({ queryKey: functionGraphKeys.detail(params.id), queryFn: () => getClient() .functionGraph.findOne({ id: params.id, select: args.select, }) .unwrap(), }); }