/**
 * Raw resource usage log — interval-accounting measurements from heartbeats (self) and the reconciler (observer)
 * @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 { platformResourceUsageLogKeys } from '../query-keys';
import { platformResourceUsageLogMutationKeys } from '../mutation-keys';
export function useUpdatePlatformResourceUsageLogMutation(params) {
    const args = buildSelectionArgs(params.selection);
    const { selection: _selection, ...mutationOptions } = params ?? {};
    void _selection;
    const queryClient = useQueryClient();
    return useMutation({
        mutationKey: platformResourceUsageLogMutationKeys.all,
        mutationFn: ({ id, sampledAt, platformResourceUsageLogPatch, }) => getClient()
            .platformResourceUsageLog.update({
            where: {
                id,
                sampledAt,
            },
            data: platformResourceUsageLogPatch,
            select: args.select,
        })
            .unwrap(),
        onSuccess: (_, variables) => {
            queryClient.invalidateQueries({
                queryKey: platformResourceUsageLogKeys.detail(variables.id),
            });
            queryClient.invalidateQueries({
                queryKey: platformResourceUsageLogKeys.lists(),
            });
        },
        ...mutationOptions,
    });
}
