/**
 * 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 { appLimitCapKeys } from '../query-keys';
import { appLimitCapMutationKeys } from '../mutation-keys';
export function useUpdateAppLimitCapMutation(params) {
    const args = buildSelectionArgs(params.selection);
    const { selection: _selection, ...mutationOptions } = params ?? {};
    void _selection;
    const queryClient = useQueryClient();
    return useMutation({
        mutationKey: appLimitCapMutationKeys.all,
        mutationFn: ({ id, appLimitCapPatch }) => getClient()
            .appLimitCap.update({
            where: {
                id,
            },
            data: appLimitCapPatch,
            select: args.select,
        })
            .unwrap(),
        onSuccess: (_, variables) => {
            queryClient.invalidateQueries({
                queryKey: appLimitCapKeys.detail(variables.id),
            });
            queryClient.invalidateQueries({
                queryKey: appLimitCapKeys.lists(),
            });
        },
        ...mutationOptions,
    });
}
