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