/** * List query hook for SpatialRelation * @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 { spatialRelationKeys } from '../query-keys'; import type { SpatialRelationSelect, SpatialRelationWithRelations, SpatialRelationFilter, SpatialRelationOrderBy, } from '../../orm/input-types'; import type { FindManyArgs, InferSelectResult, ConnectionResult, HookStrictSelect, } from '../../orm/select-types'; export type { SpatialRelationSelect, SpatialRelationWithRelations, SpatialRelationFilter, SpatialRelationOrderBy, } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const spatialRelationsQueryKey = spatialRelationKeys.list; /** * Query hook for fetching SpatialRelation list * * @example * ```tsx * const { data, isLoading } = useSpatialRelationsQuery({ * selection: { * fields: { id: true, name: true }, * where: { name: { equalTo: "example" } }, * orderBy: ['CREATED_AT_DESC'], * first: 10, * }, * }); * ``` */ export function useSpatialRelationsQuery< S extends SpatialRelationSelect, TData = { spatialRelations: ConnectionResult>; }, >( params: { selection: { fields: S; } & Omit, 'fields'> & HookStrictSelect, SpatialRelationSelect>; } & Omit< UseQueryOptions< { spatialRelations: ConnectionResult>; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function useSpatialRelationsQuery( params: { selection: ListSelectionConfig< SpatialRelationSelect, SpatialRelationFilter, SpatialRelationOrderBy >; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildListSelectionArgs< SpatialRelationSelect, SpatialRelationFilter, SpatialRelationOrderBy >(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: spatialRelationKeys.list(args), queryFn: () => getClient().spatialRelation.findMany(args).unwrap(), ...queryOptions, }); } /** * Fetch SpatialRelation list without React hooks * * @example * ```ts * const data = await fetchSpatialRelationsQuery({ * selection: { * fields: { id: true }, * first: 10, * }, * }); * ``` */ export async function fetchSpatialRelationsQuery(params: { selection: { fields: S; } & Omit, 'fields'> & HookStrictSelect, SpatialRelationSelect>; }): Promise<{ spatialRelations: ConnectionResult>; }>; export async function fetchSpatialRelationsQuery(params: { selection: ListSelectionConfig< SpatialRelationSelect, SpatialRelationFilter, SpatialRelationOrderBy >; }) { const args = buildListSelectionArgs< SpatialRelationSelect, SpatialRelationFilter, SpatialRelationOrderBy >(params.selection); return getClient().spatialRelation.findMany(args).unwrap(); } /** * Prefetch SpatialRelation list for SSR or cache warming * * @example * ```ts * await prefetchSpatialRelationsQuery(queryClient, { selection: { fields: { id: true }, first: 10 } }); * ``` */ export async function prefetchSpatialRelationsQuery( queryClient: QueryClient, params: { selection: { fields: S; } & Omit, 'fields'> & HookStrictSelect, SpatialRelationSelect>; } ): Promise; export async function prefetchSpatialRelationsQuery( queryClient: QueryClient, params: { selection: ListSelectionConfig< SpatialRelationSelect, SpatialRelationFilter, SpatialRelationOrderBy >; } ): Promise { const args = buildListSelectionArgs< SpatialRelationSelect, SpatialRelationFilter, SpatialRelationOrderBy >(params.selection); await queryClient.prefetchQuery({ queryKey: spatialRelationKeys.list(args), queryFn: () => getClient().spatialRelation.findMany(args).unwrap(), }); }