/**
 * Update mutation hook for LimitsModule
 * @generated by @constructive-io/graphql-codegen
 * DO NOT EDIT - changes will be overwritten
 */
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { getClient } from '../client';
import { buildSelectionArgs } from '../selection';
import { limitsModuleKeys } from '../query-keys';
import { limitsModuleMutationKeys } from '../mutation-keys';
export function useUpdateLimitsModuleMutation(params) {
    const args = buildSelectionArgs(params.selection);
    const { selection: _selection, ...mutationOptions } = params ?? {};
    void _selection;
    const queryClient = useQueryClient();
    return useMutation({
        mutationKey: limitsModuleMutationKeys.all,
        mutationFn: ({ id, limitsModulePatch }) => getClient()
            .limitsModule.update({
            where: {
                id,
            },
            data: limitsModulePatch,
            select: args.select,
        })
            .unwrap(),
        onSuccess: (_, variables) => {
            queryClient.invalidateQueries({
                queryKey: limitsModuleKeys.detail(variables.id),
            });
            queryClient.invalidateQueries({
                queryKey: limitsModuleKeys.lists(),
            });
        },
        ...mutationOptions,
    });
}
