/**
 * Records of ownership transfers and grants between members
 * @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 { orgOwnerGrantKeys } from '../query-keys';
import { orgOwnerGrantMutationKeys } from '../mutation-keys';
export function useUpdateOrgOwnerGrantMutation(params) {
    const args = buildSelectionArgs(params.selection);
    const { selection: _selection, ...mutationOptions } = params ?? {};
    void _selection;
    const queryClient = useQueryClient();
    return useMutation({
        mutationKey: orgOwnerGrantMutationKeys.all,
        mutationFn: ({ id, orgOwnerGrantPatch, }) => getClient()
            .orgOwnerGrant.update({
            where: {
                id,
            },
            data: orgOwnerGrantPatch,
            select: args.select,
        })
            .unwrap(),
        onSuccess: (_, variables) => {
            queryClient.invalidateQueries({
                queryKey: orgOwnerGrantKeys.detail(variables.id),
            });
            queryClient.invalidateQueries({
                queryKey: orgOwnerGrantKeys.lists(),
            });
        },
        ...mutationOptions,
    });
}
