DESCRIPTION
This error you may be facing while making a simple call to apex method from LWC and any record is being created, updated or deleted.
SOLUTION
If the apex method you are invoking from LWC is annotated as cacheable=true then you can not make any DML in that context. So, in order to avoid this issue, please remove this cacheable=true.
Previously:
@AuraEnabled(cacheable=true)
public static String updateStatus(Id caseId) {
Case c = new Case(Id= caseId);
c.Status = 'New';
update c;
}
Now
@AuraEnabled
public static String updateStatus(Id caseId) {
Case c = new Case(Id= caseId);
c.Status = 'New';
update c;
}