Calling Apex from Lightning returning a class extending an Abstract class

I have found an issue that when calling an Apex method from Lightning that returns a class that extends an abstract class, then only the @AuraEnabled getters from the concrete class are returned, the getters from the base abstract class are not.

BaseThing

public abstract class BaseThing {

    @AuraEnabled
    public String getOne() {
        return '1';
    }

    @AuraEnabled
    public String getTwo() {
        return '2';
    }

}

ConcreteThing

public class ConcreteThing extends BaseThing {

    @AuraEnabled
    public String getThree() {
        return '3';
    }

    @AuraEnabled
    public String getFour() {
        return '4';
    }

}

NumberController

public class NumberController {

    @AuraEnabled
    public static ConcreteThing GetConcreteThing()
    {
        return new ConcreteThing();
    }

}

As you can see from the screenshot of the Lightning Inspector, when this Apex action is called only the getters from the concrete class are returned:

View of action from Lightning Inspector

Is this supposed to be supported, or is this a bug? I can’t see anywhere in the Lightning documentation that states that this isn’t supported.

Answer

I have had a response from the product manager at Salesforce that this is indeed a bug. It is logged as W-3176751, although it doesn’t seem to appear on the known issues site at the moment.

I am awaiting a response regarding it’s public visibility on the Known Issues site and the expected fix date.

Attribution
Source : Link , Question Author : Mark Keats , Answer Author : Mark Keats

Leave a Comment