/** * Fully-qualified hostnames owned by this scope; each row claims its hostname globally through the catalog * @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 { platformDomainKeys } from '../query-keys'; import type { PlatformDomainSelect, PlatformDomainWithRelations } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { PlatformDomainSelect, PlatformDomainWithRelations } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const platformDomainQueryKey = platformDomainKeys.detail; /** * Fully-qualified hostnames owned by this scope; each row claims its hostname globally through the catalog * * @example * ```tsx * const { data, isLoading } = usePlatformDomainQuery({ * id: 'some-id', * selection: { fields: { id: true, name: true } }, * }); * ``` */ export function usePlatformDomainQuery< S extends PlatformDomainSelect, TData = { platformDomain: InferSelectResult | null; }, >( params: { id: string; selection: { fields: S; } & HookStrictSelect, PlatformDomainSelect>; } & Omit< UseQueryOptions< { platformDomain: InferSelectResult | null; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function usePlatformDomainQuery( params: { id: string; selection: SelectionConfig; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: platformDomainKeys.detail(params.id), queryFn: () => getClient() .platformDomain.findOne({ id: params.id, select: args.select, }) .unwrap(), ...queryOptions, }); } /** * Fully-qualified hostnames owned by this scope; each row claims its hostname globally through the catalog * * @example * ```ts * const data = await fetchPlatformDomainQuery({ * id: 'some-id', * selection: { fields: { id: true } }, * }); * ``` */ export async function fetchPlatformDomainQuery(params: { id: string; selection: { fields: S; } & HookStrictSelect, PlatformDomainSelect>; }): Promise<{ platformDomain: InferSelectResult | null; }>; export async function fetchPlatformDomainQuery(params: { id: string; selection: SelectionConfig; }): Promise { const args = buildSelectionArgs(params.selection); return getClient() .platformDomain.findOne({ id: params.id, select: args.select, }) .unwrap(); } /** * Fully-qualified hostnames owned by this scope; each row claims its hostname globally through the catalog * * @example * ```ts * await prefetchPlatformDomainQuery(queryClient, { id: 'some-id', selection: { fields: { id: true } } }); * ``` */ export async function prefetchPlatformDomainQuery( queryClient: QueryClient, params: { id: string; selection: { fields: S; } & HookStrictSelect, PlatformDomainSelect>; } ): Promise; export async function prefetchPlatformDomainQuery( queryClient: QueryClient, params: { id: string; selection: SelectionConfig; } ): Promise { const args = buildSelectionArgs(params.selection); await queryClient.prefetchQuery({ queryKey: platformDomainKeys.detail(params.id), queryFn: () => getClient() .platformDomain.findOne({ id: params.id, select: args.select, }) .unwrap(), }); }