We are building a product that will make use of multiple Lightning Web Components (LWCs), and some of those will make use of @AuraEnabled
Apex methods. We also plan to provide an API that non-LWC UI can access. (In the past, we have provided such APIs by using @RestResource
Apex classes receiving and sending JSON.)
Our present idea is to go ahead and build the @AuraEnabled
Apex code methods/classes first, and then later wrap them in a single @RestResource
Apex class that dispatches the requests according to the URL pattern to the relevant @AuraEnabled
methods/classes. (I assume in this case the @AuraEnabled(cacheable=true)
annotation will be ignored.)
Has anyone done this? Pros/cons?
@AuraEnabled
method calls a plain method (also called by the@RestResource
code), but then that is close to what I am already proposing. The only extra concern for the@AuraEnabled
case is the@AuraEnabled
annotation...