I am having a dilemma of what kind of query shall I make
Imagine that I'm inside a Details View of an object named Merchandise and of course, with the scope of LWC coding here, the recordID is focused on the Merchandise's.
I want to create a Lightning Tree where I can display the Production Requests related to the Merchandise and put the related Purchase Requests of these Production Requests as sub-trees.
But it seems Salesforce / APEX isn't allowing sub-queries of up to 3rd level.
Legend: PR = Production Request PuR = Purchase Request
Relationships Merchandise has many Production Requests Production Request has many Purchase Requests
Mechandise > Production Requests > Purchase Requests (this is the database structure)
I tried querying this
List<Merchandise__c> merchanList = [SELECT ID (SELECT ID, (SELECT ID FROM Purchase_Requests__r) FROM Production_Requests__r) FROM Merchandise__c)]
And APEX is telling me that I can't query for more than 2 levels of relationship.
Can someone kindly give me a good query or work around for my desired SOQL please? Thank you very much in advance!