/**
 * DNS domain and subdomain routing: maps hostnames to either an API endpoint or a site
 * @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 { domainKeys } from '../query-keys';
import { domainMutationKeys } from '../mutation-keys';
export function useUpdateDomainMutation(params) {
    const args = buildSelectionArgs(params.selection);
    const { selection: _selection, ...mutationOptions } = params ?? {};
    void _selection;
    const queryClient = useQueryClient();
    return useMutation({
        mutationKey: domainMutationKeys.all,
        mutationFn: ({ id, domainPatch }) => getClient()
            .domain.update({
            where: {
                id,
            },
            data: domainPatch,
            select: args.select,
        })
            .unwrap(),
        onSuccess: (_, variables) => {
            queryClient.invalidateQueries({
                queryKey: domainKeys.detail(variables.id),
            });
            queryClient.invalidateQueries({
                queryKey: domainKeys.lists(),
            });
        },
        ...mutationOptions,
    });
}
