/**
 * Resource lifecycle events — audit log of provisioning, updates, and failure events
 * @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 { platformResourceEventKeys } from '../query-keys';
import { platformResourceEventMutationKeys } from '../mutation-keys';
export function useUpdatePlatformResourceEventMutation(params) {
    const args = buildSelectionArgs(params.selection);
    const { selection: _selection, ...mutationOptions } = params ?? {};
    void _selection;
    const queryClient = useQueryClient();
    return useMutation({
        mutationKey: platformResourceEventMutationKeys.all,
        mutationFn: ({ id, createdAt, platformResourceEventPatch, }) => getClient()
            .platformResourceEvent.update({
            where: {
                id,
                createdAt,
            },
            data: platformResourceEventPatch,
            select: args.select,
        })
            .unwrap(),
        onSuccess: (_, variables) => {
            queryClient.invalidateQueries({
                queryKey: platformResourceEventKeys.detail(variables.id),
            });
            queryClient.invalidateQueries({
                queryKey: platformResourceEventKeys.lists(),
            });
        },
        ...mutationOptions,
    });
}
