/**
 * Per-entity cap overrides. Allows specific orgs/entities to have different cap values than the scope default.
 * @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 { orgLimitCapKeys } from '../query-keys';
import { orgLimitCapMutationKeys } from '../mutation-keys';
export function useUpdateOrgLimitCapMutation(params) {
    const args = buildSelectionArgs(params.selection);
    const { selection: _selection, ...mutationOptions } = params ?? {};
    void _selection;
    const queryClient = useQueryClient();
    return useMutation({
        mutationKey: orgLimitCapMutationKeys.all,
        mutationFn: ({ id, orgLimitCapPatch }) => getClient()
            .orgLimitCap.update({
            where: {
                id,
            },
            data: orgLimitCapPatch,
            select: args.select,
        })
            .unwrap(),
        onSuccess: (_, variables) => {
            queryClient.invalidateQueries({
                queryKey: orgLimitCapKeys.detail(variables.id),
            });
            queryClient.invalidateQueries({
                queryKey: orgLimitCapKeys.lists(),
            });
        },
        ...mutationOptions,
    });
}
