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