Salesforce Certified Platform Developer II — Question 70
A developer must perform a complex SOQL query that joins two objects in a Lightning component.
How can the Lightning component execute the query?
Answer options
- A. Invoke an Apex class with the method annotated as @AuraEnabled to perform the query
- B. Use the Salesforce Streaming API to perform the SOQL query
- C. Create a Process Builder to execute the query and invoke from the Lightning component
- D. Write the query in a custom Lightning web component wrapper and invoke from the Lightning component
Correct answer: A
Explanation
The correct answer is A because invoking an Apex class with an @AuraEnabled method is the appropriate way to perform SOQL queries in Lightning components. Option B is incorrect as the Streaming API is meant for real-time data updates, not for executing queries. Option C is not suitable since Process Builder is not designed for executing SOQL queries directly. Option D is also incorrect as it suggests an unnecessary complexity by wrapping the query in another component.