/**
 * Unified K8s resource declarations — stores desired state (spec) and observed state (status) for all resource kinds within a namespace
 * @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 { platformResourceKeys } from '../query-keys';
import { platformResourceMutationKeys } from '../mutation-keys';
export function useUpdatePlatformResourceMutation(params) {
    const args = buildSelectionArgs(params.selection);
    const { selection: _selection, ...mutationOptions } = params ?? {};
    void _selection;
    const queryClient = useQueryClient();
    return useMutation({
        mutationKey: platformResourceMutationKeys.all,
        mutationFn: ({ id, platformResourcePatch, }) => getClient()
            .platformResource.update({
            where: {
                id,
            },
            data: platformResourcePatch,
            select: args.select,
        })
            .unwrap(),
        onSuccess: (_, variables) => {
            queryClient.invalidateQueries({
                queryKey: platformResourceKeys.detail(variables.id),
            });
            queryClient.invalidateQueries({
                queryKey: platformResourceKeys.lists(),
            });
        },
        ...mutationOptions,
    });
}
