Why can an Apex Rest service not be annodated as @ReadOnly?

In apex you can create your own REST services quite simply:

@RestResource(urlMapping='/DUMMY/v1/*')
global class REST_Service {
@HttpGet
    global static string getDummytMessage(){
        return 'DUMMY DATA';
    }
}

Salesforce does not allow such a class to be annotated as @ReadOnly, I would like to understand and know why this is the case.

update: potentially there is no technical reason and its just not there out of a project management perspective. I’ve created an idea to put it on the radar.

Answer

Thats a good question, and a reasonable one given that it is supported for Web Services defined via Apex. As to the reason for this, given both contexts are functionally the same from our perspective as developers. I am at a loss as to provide a reasonable hypothesis outside of knowning the code base of the platform.

I would suggest raising an IdeaExchange for it (had a quick check and could not see one) and perhaps raising a support case to enquiry as to if this is at all on the immediate radar to release this support.

Attribution
Source : Link , Question Author : Samuel De Rycke , Answer Author : Andrew Fawcett

Leave a Comment