"use strict";
/**
 * 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
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.useUpdateRelationProvisionMutation = useUpdateRelationProvisionMutation;
const react_query_1 = require("@tanstack/react-query");
const client_1 = require("../client");
const selection_1 = require("../selection");
const query_keys_1 = require("../query-keys");
const mutation_keys_1 = require("../mutation-keys");
function useUpdateRelationProvisionMutation(params) {
    const args = (0, selection_1.buildSelectionArgs)(params.selection);
    const { selection: _selection, ...mutationOptions } = params ?? {};
    void _selection;
    const queryClient = (0, react_query_1.useQueryClient)();
    return (0, react_query_1.useMutation)({
        mutationKey: mutation_keys_1.relationProvisionMutationKeys.all,
        mutationFn: ({ id, relationProvisionPatch, }) => (0, client_1.getClient)()
            .relationProvision.update({
            where: {
                id,
            },
            data: relationProvisionPatch,
            select: args.select,
        })
            .unwrap(),
        onSuccess: (_, variables) => {
            queryClient.invalidateQueries({
                queryKey: query_keys_1.relationProvisionKeys.detail(variables.id),
            });
            queryClient.invalidateQueries({
                queryKey: query_keys_1.relationProvisionKeys.lists(),
            });
        },
        ...mutationOptions,
    });
}
