/**
 * Append-only ledger of credit grants that automatically update limit ceilings
 * @generated by @constructive-io/graphql-codegen
 * DO NOT EDIT - changes will be overwritten
 */
import { useQuery } from '@tanstack/react-query';
import { getClient } from '../client';
import { buildSelectionArgs } from '../selection';
import { orgLimitCreditKeys } from '../query-keys';
/** Query key factory - re-exported from query-keys.ts */
export const orgLimitCreditQueryKey = orgLimitCreditKeys.detail;
export function useOrgLimitCreditQuery(params) {
    const args = buildSelectionArgs(params.selection);
    const { selection: _selection, ...queryOptions } = params ?? {};
    void _selection;
    return useQuery({
        queryKey: orgLimitCreditKeys.detail(params.id),
        queryFn: () => getClient()
            .orgLimitCredit.findOne({
            id: params.id,
            select: args.select,
        })
            .unwrap(),
        ...queryOptions,
    });
}
export async function fetchOrgLimitCreditQuery(params) {
    const args = buildSelectionArgs(params.selection);
    return getClient()
        .orgLimitCredit.findOne({
        id: params.id,
        select: args.select,
    })
        .unwrap();
}
export async function prefetchOrgLimitCreditQuery(queryClient, params) {
    const args = buildSelectionArgs(params.selection);
    await queryClient.prefetchQuery({
        queryKey: orgLimitCreditKeys.detail(params.id),
        queryFn: () => getClient()
            .orgLimitCredit.findOne({
            id: params.id,
            select: args.select,
        })
            .unwrap(),
    });
}
