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