/** * Branch heads — mutable pointers into the commit chain * @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 { functionGraphRefKeys } from '../query-keys'; import type { FunctionGraphRefSelect, FunctionGraphRefWithRelations } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { FunctionGraphRefSelect, FunctionGraphRefWithRelations } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const functionGraphRefQueryKey = functionGraphRefKeys.detail; /** * Branch heads — mutable pointers into the commit chain * * @example * ```tsx * const { data, isLoading } = useFunctionGraphRefQuery({ * id: 'some-id', * selection: { fields: { id: true, name: true } }, * }); * ``` */ export function useFunctionGraphRefQuery< S extends FunctionGraphRefSelect, TData = { functionGraphRef: InferSelectResult | null; }, >( params: { id: string; selection: { fields: S; } & HookStrictSelect, FunctionGraphRefSelect>; } & Omit< UseQueryOptions< { functionGraphRef: InferSelectResult | null; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function useFunctionGraphRefQuery( params: { id: string; selection: SelectionConfig; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: functionGraphRefKeys.detail(params.id), queryFn: () => getClient() .functionGraphRef.findOne({ id: params.id, select: args.select, }) .unwrap(), ...queryOptions, }); } /** * Branch heads — mutable pointers into the commit chain * * @example * ```ts * const data = await fetchFunctionGraphRefQuery({ * id: 'some-id', * selection: { fields: { id: true } }, * }); * ``` */ export async function fetchFunctionGraphRefQuery(params: { id: string; selection: { fields: S; } & HookStrictSelect, FunctionGraphRefSelect>; }): Promise<{ functionGraphRef: InferSelectResult | null; }>; export async function fetchFunctionGraphRefQuery(params: { id: string; selection: SelectionConfig; }): Promise { const args = buildSelectionArgs(params.selection); return getClient() .functionGraphRef.findOne({ id: params.id, select: args.select, }) .unwrap(); } /** * Branch heads — mutable pointers into the commit chain * * @example * ```ts * await prefetchFunctionGraphRefQuery(queryClient, { id: 'some-id', selection: { fields: { id: true } } }); * ``` */ export async function prefetchFunctionGraphRefQuery( queryClient: QueryClient, params: { id: string; selection: { fields: S; } & HookStrictSelect, FunctionGraphRefSelect>; } ): Promise; export async function prefetchFunctionGraphRefQuery( queryClient: QueryClient, params: { id: string; selection: SelectionConfig; } ): Promise { const args = buildSelectionArgs(params.selection); await queryClient.prefetchQuery({ queryKey: functionGraphRefKeys.detail(params.id), queryFn: () => getClient() .functionGraphRef.findOne({ id: params.id, select: args.select, }) .unwrap(), }); }