/** * Binds a site to the identity it sends as. Unique on site_id: one identity per site, but many sites may share an identity. * @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 { emailSiteIdentityKeys } from '../query-keys'; import type { EmailSiteIdentitySelect, EmailSiteIdentityWithRelations, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { EmailSiteIdentitySelect, EmailSiteIdentityWithRelations, } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const emailSiteIdentityQueryKey = emailSiteIdentityKeys.detail; /** * Binds a site to the identity it sends as. Unique on site_id: one identity per site, but many sites may share an identity. * * @example * ```tsx * const { data, isLoading } = useEmailSiteIdentityQuery({ * id: 'some-id', * selection: { fields: { id: true, name: true } }, * }); * ``` */ export function useEmailSiteIdentityQuery< S extends EmailSiteIdentitySelect, TData = { emailSiteIdentity: InferSelectResult | null; }, >( params: { id: string; selection: { fields: S; } & HookStrictSelect, EmailSiteIdentitySelect>; } & Omit< UseQueryOptions< { emailSiteIdentity: InferSelectResult | null; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function useEmailSiteIdentityQuery( params: { id: string; selection: SelectionConfig; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: emailSiteIdentityKeys.detail(params.id), queryFn: () => getClient() .emailSiteIdentity.findOne({ id: params.id, select: args.select, }) .unwrap(), ...queryOptions, }); } /** * Binds a site to the identity it sends as. Unique on site_id: one identity per site, but many sites may share an identity. * * @example * ```ts * const data = await fetchEmailSiteIdentityQuery({ * id: 'some-id', * selection: { fields: { id: true } }, * }); * ``` */ export async function fetchEmailSiteIdentityQuery(params: { id: string; selection: { fields: S; } & HookStrictSelect, EmailSiteIdentitySelect>; }): Promise<{ emailSiteIdentity: InferSelectResult | null; }>; export async function fetchEmailSiteIdentityQuery(params: { id: string; selection: SelectionConfig; }): Promise { const args = buildSelectionArgs(params.selection); return getClient() .emailSiteIdentity.findOne({ id: params.id, select: args.select, }) .unwrap(); } /** * Binds a site to the identity it sends as. Unique on site_id: one identity per site, but many sites may share an identity. * * @example * ```ts * await prefetchEmailSiteIdentityQuery(queryClient, { id: 'some-id', selection: { fields: { id: true } } }); * ``` */ export async function prefetchEmailSiteIdentityQuery( queryClient: QueryClient, params: { id: string; selection: { fields: S; } & HookStrictSelect, EmailSiteIdentitySelect>; } ): Promise; export async function prefetchEmailSiteIdentityQuery( queryClient: QueryClient, params: { id: string; selection: SelectionConfig; } ): Promise { const args = buildSelectionArgs(params.selection); await queryClient.prefetchQuery({ queryKey: emailSiteIdentityKeys.detail(params.id), queryFn: () => getClient() .emailSiteIdentity.findOne({ id: params.id, select: args.select, }) .unwrap(), }); }