/**
 * Function invocation log — INSERT to call a function (business-layer, metered). Linked to definitions by task_identifier string.
 * @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 { orgFunctionInvocationKeys } from '../query-keys';
import { orgFunctionInvocationMutationKeys } from '../mutation-keys';
export function useUpdateOrgFunctionInvocationMutation(params) {
    const args = buildSelectionArgs(params.selection);
    const { selection: _selection, ...mutationOptions } = params ?? {};
    void _selection;
    const queryClient = useQueryClient();
    return useMutation({
        mutationKey: orgFunctionInvocationMutationKeys.all,
        mutationFn: ({ id, createdAt, orgFunctionInvocationPatch, }) => getClient()
            .orgFunctionInvocation.update({
            where: {
                id,
                createdAt,
            },
            data: orgFunctionInvocationPatch,
            select: args.select,
        })
            .unwrap(),
        onSuccess: (_, variables) => {
            queryClient.invalidateQueries({
                queryKey: orgFunctionInvocationKeys.detail(variables.id),
            });
            queryClient.invalidateQueries({
                queryKey: orgFunctionInvocationKeys.lists(),
            });
        },
        ...mutationOptions,
    });
}
