# Calling Apex from LWC and Aura components

*Platform Developer II Study Guide · User Interface · Last updated October 16, 2026 · https://www.certifyforce.com/study-guide/platform-developer-ii/user-interface/calling-apex-from-lwc-and-aura-components*

How to read an LWC or Aura component and its Apex controller and spot the fix: cacheable wires versus imperative calls, reactive parameters and undefined values, refreshApex, immutable wired data, the Aura server-action lifecycle and the @AuraEnabled rules for methods and wrapper classes.

- Certification: Salesforce Platform Developer II
- Exam section: User Interface
- Study guide: https://www.certifyforce.com/study-guide/platform-developer-ii

**Official exam objective:**

> Given requirements and code snippets for a LWC or Aura Component and its Apex controller class, analyze determine any changes.

## What the exam expects

- Read an LWC and its Apex method and decide whether the call must be wired or imperative, and what annotation the method needs.
- Spot parameter mistakes: a bare value instead of a parameter object, a missing `$`, or an `undefined` reactive value that stops the wire.
- Refresh wired Apex data correctly with `refreshApex()` and change provisioned data without mutating it.
- Fix an Aura client-side controller that never reaches the server, or whose attribute change made outside the framework never rerenders.
- Apply the `@AuraEnabled` rules for static methods, wrapper-class properties, unique action names and overloads.

Key terms: **cacheable method** (an `@AuraEnabled(cacheable=true)` method that only reads, required for `@wire`), **reactive parameter** (a `$`-prefixed wire parameter bound to a component property), **wire-emitted value** (the object the wire service provisions, which `refreshApex()` takes), **server-side action** (an Aura action created with `component.get("c.method")`), **`$A.getCallback()`** (the wrapper that brings code back into the Aura lifecycle).

The PD I basics (exposing methods, wire versus imperative in general, `AuraHandledException`) are in the Platform Developer guide's *Apex for page components: controllers and wire adapters*; this unit is the code-reading layer on top.

## Key facts

| Fact | Detail | Source |
|---|---|---|
| `@wire` to Apex | Method must be `@AuraEnabled(cacheable=true)`, static, public or global | [Wire Apex Methods](https://developer.salesforce.com/docs/platform/lwc/guide/apex-wire-method.html) |
| Cacheable methods | May only get data, never change it | [Client-Side Caching](https://developer.salesforce.com/docs/platform/lwc/guide/apex-result-caching.html) |
| Insert, update, delete | Must be called imperatively | [Call Apex Methods Imperatively](https://developer.salesforce.com/docs/platform/lwc/guide/apex-call-imperative.html) |
| Parameters | An object whose properties match the Apex parameter names; Maps unsupported | [Call Apex Methods Imperatively](https://developer.salesforce.com/docs/platform/lwc/guide/apex-call-imperative.html) |
| Wire parameter `undefined` | Method isn't called; `null` calls it | [Wire Apex Methods](https://developer.salesforce.com/docs/platform/lwc/guide/apex-wire-method.html) |
| `refreshApex()` argument | An object previously emitted by an Apex `@wire` | [Client-Side Caching](https://developer.salesforce.com/docs/platform/lwc/guide/apex-result-caching.html) |
| Provisioned Apex data | Treat as immutable; shallow-copy to change | [Call Apex Methods](https://developer.salesforce.com/docs/platform/lwc/guide/apex.html) |
| Aura action send | `$A.enqueueAction(action)` queues it; batched at end of event loop | [Calling a Server-Side Action](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_actions_call.htm) |
| Aura callback states | SUCCESS, ERROR, INCOMPLETE (ABORTED deprecated) | [Action States](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_actions_states.htm) |
| `setTimeout()` in Aura | Wrap in `$A.getCallback()` so the component rerenders | [Outside the Framework Lifecycle](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cb_mod_ext_js.htm) |
| Wrapper serialization | Only `@AuraEnabled` public instance members are returned | [Returning Data from Apex](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_apex_returning_data.htm) |
| Overloads | Not allowed on `@AuraEnabled` methods from API 55.0 | [AuraEnabled Annotation](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_AuraEnabled.htm) |

## Check yourself

- Why does a wired Apex method that inserts records violate the platform's rules?
- When does a wire with a `$` parameter skip calling Apex?
- When does Aura code need `$A.getCallback()`?
- Which wrapper-class members reach the component?

## Sources

- [Wire Apex Methods to Lightning Web Components](https://developer.salesforce.com/docs/platform/lwc/guide/apex-wire-method.html)
- [Call Apex Methods Imperatively](https://developer.salesforce.com/docs/platform/lwc/guide/apex-call-imperative.html)
- [Client-Side Caching of Apex Method Results](https://developer.salesforce.com/docs/platform/lwc/guide/apex-result-caching.html)
- [Call Apex Methods](https://developer.salesforce.com/docs/platform/lwc/guide/apex.html)
- [Data Guidelines](https://developer.salesforce.com/docs/platform/lwc/guide/data-guidelines.html)
- [Expose Apex Methods to Lightning Web Components](https://developer.salesforce.com/docs/platform/lwc/guide/apex-expose-method.html)
- [Apex Server-Side Controller Overview](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_apex.htm)
- [Calling a Server-Side Action](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_actions_call.htm)
- [Action States](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_actions_states.htm)
- [Storable Actions](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_storable_actions.htm)
- [Returning Data from an Apex Server-Side Controller](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_apex_returning_data.htm)
- [Modifying Components Outside the Framework Lifecycle](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cb_mod_ext_js.htm)
- [AuraEnabled Annotation](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_AuraEnabled.htm)

## About the full unit

The "Core concepts", "Exam traps" and "Worked scenario" sections of this unit, its 11 linked practice questions, and unlimited timed mock exams are included with the Platform Developer II pack (USD $19): https://www.certifyforce.com/practice-exams
