Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 977 Bytes

valid-apex-method-invocation.md

File metadata and controls

28 lines (19 loc) · 977 Bytes

Enforce invoking Apex methods with the right arguments (valid-apex-method-invocation)

Apex methods can be imported inside LWC modules via the @salesforce/apex scoped import. The method can be imperatively invoked by calling the module default import. Apex methods expect to receive its arguments as an object where each object key maps to Apex method parameter name.

Rules details

This rule ensure that the Apex method receives its arguments as an object.

Example of incorrect code:

import { findContacts } from '@salesforce/apex/ContactController.findContacts';

findContacts('Ted');
findContacts('Ted', 'Salesforce');

Example of correct code:

import { findContacts } from '@salesforce/apex/ContactController.findContacts';

findContacts({ searchKey: 'Ted' });
findContacts({
    searchKey: 'Ted',
    company: 'Salesforce',
});