/**
 * API endpoint configurations: each record defines a PostGraphile/PostgREST API with its database role and public access settings
 * @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 { apiKeys } from '../query-keys';
/** Query key factory - re-exported from query-keys.ts */
export const apiQueryKey = apiKeys.detail;
export function useApiQuery(params) {
    const args = buildSelectionArgs(params.selection);
    const { selection: _selection, ...queryOptions } = params ?? {};
    void _selection;
    return useQuery({
        queryKey: apiKeys.detail(params.id),
        queryFn: () => getClient()
            .api.findOne({
            id: params.id,
            select: args.select,
        })
            .unwrap(),
        ...queryOptions,
    });
}
export async function fetchApiQuery(params) {
    const args = buildSelectionArgs(params.selection);
    return getClient()
        .api.findOne({
        id: params.id,
        select: args.select,
    })
        .unwrap();
}
export async function prefetchApiQuery(queryClient, params) {
    const args = buildSelectionArgs(params.selection);
    await queryClient.prefetchQuery({
        queryKey: apiKeys.detail(params.id),
        queryFn: () => getClient()
            .api.findOne({
            id: params.id,
            select: args.select,
        })
            .unwrap(),
    });
}
