GraphQL Mutations in LWC | Create, Update, and Delete Without Apex
GraphQL mutations now enable Salesforce developers to create, update, and delete records directly within Lightning Web Components without using Apex. By using the executeMutation function from lightning/graphql, CRUD operations can be performed imperatively with simpler, Apex-free code. This shift allows faster, more efficient data-driven UI development in LWC, supporting bulk mutations and reducing boilerplate. It’s a practical way to enhance LWC apps using native UI API-supported objects and improves data consistency through Lightning Data Service integration. Teams can build fully CRUD-capable LWC components unburdened by Apex wrappers.
- Use executeMutation from lightning/graphql for imperative GraphQL mutations in LWC.
- Always include required fields and call refresh after creating records to update queries.
- For updates, provide record Id and only updateable fields; refresh if data mismatch occurs.
- Deletes require only Id; Lightning Data Service auto-removes deleted records from cache.
- GraphQL mutations support only UI API-enabled sObjects; use Apex for complex logic or unsupported objects.
No more Apex wrappers for basic DML. executeMutation brings full record write operations directly to your LWC JavaScript. ⚡ SalesforceBolt — Source Code batra-kapil / salesforcebolt-lwc — graphql-mutations Full working examples: create, update, and delete with executeMutation The GraphQL wire adapter in LWC has been great for reading data reactively. But write operations — creating, updating, deleting records — still needed Apex. That changes now. executeMutation from lightning/graphql brings full DML capability directly to LWC JavaScript, no Apex required. What's New According to the official Salesforce Developer Blog , GraphQL mutations are now available in LWC. Salesforce introduced the newest version of the GraphQL wire adapter ( lightning/graphql ) in Winter '26. This release adds support for using GraphQL beyond just querying — adding the ability to create, update, and delete records via the GraphQL Mutations API.