Lightning: Need help understanding @AuraEnabled(cacheable=true)

apexaura-enabledcacheabledocumentationlightning-aura-components

Going through the Developer Guide I found this statement.

To set cacheable=true, a method must only get data. It can’t mutate data.

Does data mutation only refer to DML operations?

I have a method to retrieve multiple records but I need to return them as a list of Wrapper objects. So I am running the retrieved records through a FOR loop. Would this be considered as altering the data? Would the method not cache the results on the client in this case?

If so, is there another approach to this?

Best Answer

The restriction is only about making permanent database changes, such as a DML statement, calling a future method, etc. Modifying data in memory is allowed.