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