/**
 * Records of individual permission grants and revocations for members via bitmask
 * @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 { orgGrantKeys } from '../query-keys';
import { orgGrantMutationKeys } from '../mutation-keys';
export function useUpdateOrgGrantMutation(params) {
    const args = buildSelectionArgs(params.selection);
    const { selection: _selection, ...mutationOptions } = params ?? {};
    void _selection;
    const queryClient = useQueryClient();
    return useMutation({
        mutationKey: orgGrantMutationKeys.all,
        mutationFn: ({ id, orgGrantPatch }) => getClient()
            .orgGrant.update({
            where: {
                id,
            },
            data: orgGrantPatch,
            select: args.select,
        })
            .unwrap(),
        onSuccess: (_, variables) => {
            queryClient.invalidateQueries({
                queryKey: orgGrantKeys.detail(variables.id),
            });
            queryClient.invalidateQueries({
                queryKey: orgGrantKeys.lists(),
            });
        },
        ...mutationOptions,
    });
}
