/** * Named stores — one per version-controlled tree (e.g. one graph, one definition set) * @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 { databaseGraphStoreKeys } from '../query-keys'; import type { DatabaseGraphStoreSelect, DatabaseGraphStoreWithRelations, DatabaseGraphStoreFilter, DatabaseGraphStoreOrderBy, } from '../../orm/input-types'; import type { FindManyArgs, InferSelectResult, ConnectionResult, HookStrictSelect, } from '../../orm/select-types'; export type { DatabaseGraphStoreSelect, DatabaseGraphStoreWithRelations, DatabaseGraphStoreFilter, DatabaseGraphStoreOrderBy, } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const databaseGraphStoresQueryKey = databaseGraphStoreKeys.list; /** * Named stores — one per version-controlled tree (e.g. one graph, one definition set) * * @example * ```tsx * const { data, isLoading } = useDatabaseGraphStoresQuery({ * selection: { * fields: { id: true, name: true }, * where: { name: { equalTo: "example" } }, * orderBy: ['CREATED_AT_DESC'], * first: 10, * }, * }); * ``` */ export function useDatabaseGraphStoresQuery< S extends DatabaseGraphStoreSelect, TData = { databaseGraphStores: ConnectionResult>; }, >( params: { selection: { fields: S; } & Omit< ListSelectionConfig, 'fields' > & HookStrictSelect, DatabaseGraphStoreSelect>; } & Omit< UseQueryOptions< { databaseGraphStores: ConnectionResult< InferSelectResult >; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function useDatabaseGraphStoresQuery( params: { selection: ListSelectionConfig< DatabaseGraphStoreSelect, DatabaseGraphStoreFilter, DatabaseGraphStoreOrderBy >; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildListSelectionArgs< DatabaseGraphStoreSelect, DatabaseGraphStoreFilter, DatabaseGraphStoreOrderBy >(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: databaseGraphStoreKeys.list(args), queryFn: () => getClient().databaseGraphStore.findMany(args).unwrap(), ...queryOptions, }); } /** * Named stores — one per version-controlled tree (e.g. one graph, one definition set) * * @example * ```ts * const data = await fetchDatabaseGraphStoresQuery({ * selection: { * fields: { id: true }, * first: 10, * }, * }); * ``` */ export async function fetchDatabaseGraphStoresQuery(params: { selection: { fields: S; } & Omit, 'fields'> & HookStrictSelect, DatabaseGraphStoreSelect>; }): Promise<{ databaseGraphStores: ConnectionResult>; }>; export async function fetchDatabaseGraphStoresQuery(params: { selection: ListSelectionConfig< DatabaseGraphStoreSelect, DatabaseGraphStoreFilter, DatabaseGraphStoreOrderBy >; }) { const args = buildListSelectionArgs< DatabaseGraphStoreSelect, DatabaseGraphStoreFilter, DatabaseGraphStoreOrderBy >(params.selection); return getClient().databaseGraphStore.findMany(args).unwrap(); } /** * Named stores — one per version-controlled tree (e.g. one graph, one definition set) * * @example * ```ts * await prefetchDatabaseGraphStoresQuery(queryClient, { selection: { fields: { id: true }, first: 10 } }); * ``` */ export async function prefetchDatabaseGraphStoresQuery( queryClient: QueryClient, params: { selection: { fields: S; } & Omit< ListSelectionConfig, 'fields' > & HookStrictSelect, DatabaseGraphStoreSelect>; } ): Promise; export async function prefetchDatabaseGraphStoresQuery( queryClient: QueryClient, params: { selection: ListSelectionConfig< DatabaseGraphStoreSelect, DatabaseGraphStoreFilter, DatabaseGraphStoreOrderBy >; } ): Promise { const args = buildListSelectionArgs< DatabaseGraphStoreSelect, DatabaseGraphStoreFilter, DatabaseGraphStoreOrderBy >(params.selection); await queryClient.prefetchQuery({ queryKey: databaseGraphStoreKeys.list(args), queryFn: () => getClient().databaseGraphStore.findMany(args).unwrap(), }); }