/** * Partitioned append-only step and test results of a build, keyed into its log object * @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 { buildStepKeys } from '../query-keys'; import type { BuildStepSelect, BuildStepWithRelations } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { BuildStepSelect, BuildStepWithRelations } from '../../orm/input-types'; /** Query key factory - re-exported from query-keys.ts */ export const buildStepQueryKey = buildStepKeys.detail; /** * Partitioned append-only step and test results of a build, keyed into its log object * * @example * ```tsx * const { data, isLoading } = useBuildStepQuery({ * id: 'some-id', * selection: { fields: { id: true, name: true } }, * }); * ``` */ export function useBuildStepQuery< S extends BuildStepSelect, TData = { buildStep: InferSelectResult | null; }, >( params: { id: string; selection: { fields: S; } & HookStrictSelect, BuildStepSelect>; } & Omit< UseQueryOptions< { buildStep: InferSelectResult | null; }, Error, TData >, 'queryKey' | 'queryFn' > ): UseQueryResult; export function useBuildStepQuery( params: { id: string; selection: SelectionConfig; } & Omit, 'queryKey' | 'queryFn'> ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...queryOptions } = params ?? {}; void _selection; return useQuery({ queryKey: buildStepKeys.detail(params.id), queryFn: () => getClient() .buildStep.findOne({ id: params.id, select: args.select, }) .unwrap(), ...queryOptions, }); } /** * Partitioned append-only step and test results of a build, keyed into its log object * * @example * ```ts * const data = await fetchBuildStepQuery({ * id: 'some-id', * selection: { fields: { id: true } }, * }); * ``` */ export async function fetchBuildStepQuery(params: { id: string; selection: { fields: S; } & HookStrictSelect, BuildStepSelect>; }): Promise<{ buildStep: InferSelectResult | null; }>; export async function fetchBuildStepQuery(params: { id: string; selection: SelectionConfig; }): Promise { const args = buildSelectionArgs(params.selection); return getClient() .buildStep.findOne({ id: params.id, select: args.select, }) .unwrap(); } /** * Partitioned append-only step and test results of a build, keyed into its log object * * @example * ```ts * await prefetchBuildStepQuery(queryClient, { id: 'some-id', selection: { fields: { id: true } } }); * ``` */ export async function prefetchBuildStepQuery( queryClient: QueryClient, params: { id: string; selection: { fields: S; } & HookStrictSelect, BuildStepSelect>; } ): Promise; export async function prefetchBuildStepQuery( queryClient: QueryClient, params: { id: string; selection: SelectionConfig; } ): Promise { const args = buildSelectionArgs(params.selection); await queryClient.prefetchQuery({ queryKey: buildStepKeys.detail(params.id), queryFn: () => getClient() .buildStep.findOne({ id: params.id, select: args.select, }) .unwrap(), }); }