/**
 * Provisions relational structure between tables. Supports four relation types:
     - RelationBelongsTo: adds a FK field on the source table referencing the target table (child perspective: "tasks belongs to projects" -> tasks.project_id).
     - RelationHasMany: adds a FK field on the target table referencing the source table (parent perspective: "projects has many tasks" -> tasks.project_id). Inverse of BelongsTo.
     - RelationHasOne: adds a FK field with a unique constraint on the source table referencing the target table. Also supports shared-primary-key patterns where the FK field IS the primary key (set field_name to the existing PK field name).
     - RelationManyToMany: creates a junction table with FK fields to both source and target tables, delegating table creation and security to secure_table_provision.
     This is a one-and-done structural provisioner. To layer additional security onto junction tables after creation, use secure_table_provision directly.
     All operations are graceful: existing fields, FK constraints, and unique constraints are reused if found.
     The trigger never injects values the caller did not provide. All security config is forwarded to secure_table_provision as-is.
 * @generated by @constructive-io/graphql-codegen
 * DO NOT EDIT - changes will be overwritten
 */
import { useQuery } from '@tanstack/react-query';
import { getClient } from '../client';
import { buildListSelectionArgs } from '../selection';
import { relationProvisionKeys } from '../query-keys';
/** Query key factory - re-exported from query-keys.ts */
export const relationProvisionsQueryKey = relationProvisionKeys.list;
export function useRelationProvisionsQuery(params) {
    const args = buildListSelectionArgs(params.selection);
    const { selection: _selection, ...queryOptions } = params ?? {};
    void _selection;
    return useQuery({
        queryKey: relationProvisionKeys.list(args),
        queryFn: () => getClient().relationProvision.findMany(args).unwrap(),
        ...queryOptions,
    });
}
export async function fetchRelationProvisionsQuery(params) {
    const args = buildListSelectionArgs(params.selection);
    return getClient().relationProvision.findMany(args).unwrap();
}
export async function prefetchRelationProvisionsQuery(queryClient, params) {
    const args = buildListSelectionArgs(params.selection);
    await queryClient.prefetchQuery({
        queryKey: relationProvisionKeys.list(args),
        queryFn: () => getClient().relationProvision.findMany(args).unwrap(),
    });
}
