/** * Content-addressed Merkle tree objects keyed by UUID v5 hash of data + children * @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 { buildListSelectionArgs } from '../selection'; import type { ListSelectionConfig } from '../selection'; import { functionGraphObjectKeys } from '../query-keys'; import type { FunctionGraphObjectSelect, FunctionGraphObjectWithRelations, FunctionGraphObjectFilter, FunctionGraphObjectOrderBy, } from '../../orm/input-types'; import type { FindManyArgs, InferSelectResult, ConnectionResult, HookStrictSelect, } from '../../orm/select-types'; export type { FunctionGraphObjectSelect, FunctionGraphObjectWithRelations, FunctionGraphObjectFilter, FunctionGraphObjectOrderBy, } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const functionGraphObjectsQueryKey = functionGraphObjectKeys.list; /** * Content-addressed Merkle tree objects keyed by UUID v5 hash of data + children * * @example * ```tsx * const { data, isLoading } = useFunctionGraphObjectsQuery({ * selection: { * fields: { id: true, name: true }, * where: { name: { equalTo: "example" } }, * orderBy: ['CREATED_AT_DESC'], * first: 10, * }, * }); * ``` */ export function useFunctionGraphObjectsQuery< S extends FunctionGraphObjectSelect, TData = { functionGraphObjects: ConnectionResult>; }, >( params: { selection: { fields: S; } & Omit< ListSelectionConfig, 'fields' > & HookStrictSelect, FunctionGraphObjectSelect>; } & Omit< UseQueryOptions< { functionGraphObjects: ConnectionResult< InferSelectResult >; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function useFunctionGraphObjectsQuery( params: { selection: ListSelectionConfig< FunctionGraphObjectSelect, FunctionGraphObjectFilter, FunctionGraphObjectOrderBy >; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildListSelectionArgs< FunctionGraphObjectSelect, FunctionGraphObjectFilter, FunctionGraphObjectOrderBy >(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: functionGraphObjectKeys.list(args), queryFn: () => getClient().functionGraphObject.findMany(args).unwrap(), ...queryOptions, }); } /** * Content-addressed Merkle tree objects keyed by UUID v5 hash of data + children * * @example * ```ts * const data = await fetchFunctionGraphObjectsQuery({ * selection: { * fields: { id: true }, * first: 10, * }, * }); * ``` */ export async function fetchFunctionGraphObjectsQuery(params: { selection: { fields: S; } & Omit< ListSelectionConfig, 'fields' > & HookStrictSelect, FunctionGraphObjectSelect>; }): Promise<{ functionGraphObjects: ConnectionResult>; }>; export async function fetchFunctionGraphObjectsQuery(params: { selection: ListSelectionConfig< FunctionGraphObjectSelect, FunctionGraphObjectFilter, FunctionGraphObjectOrderBy >; }) { const args = buildListSelectionArgs< FunctionGraphObjectSelect, FunctionGraphObjectFilter, FunctionGraphObjectOrderBy >(params.selection); return getClient().functionGraphObject.findMany(args).unwrap(); } /** * Content-addressed Merkle tree objects keyed by UUID v5 hash of data + children * * @example * ```ts * await prefetchFunctionGraphObjectsQuery(queryClient, { selection: { fields: { id: true }, first: 10 } }); * ``` */ export async function prefetchFunctionGraphObjectsQuery( queryClient: QueryClient, params: { selection: { fields: S; } & Omit< ListSelectionConfig, 'fields' > & HookStrictSelect, FunctionGraphObjectSelect>; } ): Promise; export async function prefetchFunctionGraphObjectsQuery( queryClient: QueryClient, params: { selection: ListSelectionConfig< FunctionGraphObjectSelect, FunctionGraphObjectFilter, FunctionGraphObjectOrderBy >; } ): Promise { const args = buildListSelectionArgs< FunctionGraphObjectSelect, FunctionGraphObjectFilter, FunctionGraphObjectOrderBy >(params.selection); await queryClient.prefetchQuery({ queryKey: functionGraphObjectKeys.list(args), queryFn: () => getClient().functionGraphObject.findMany(args).unwrap(), }); }