Salesforce Developers Blog

GraphQL Mutations Now Available in LWC: Create, Update, and Delete Records

Avatar for Ben SklarBen Sklar
Avatar for Stephen CarrawayStephen Carraway
Create, update, and delete Salesforce records directly in LWC with GraphQL mutations. Streamline your data transactions and handle bulk changes without the need for custom Apex.
GraphQL Mutations Now Available in LWC: Create, Update, and Delete Records
May 05, 2026

Salesforce Developers, we have an exciting update that extends the data management story for Lightning Web Components (LWC): GraphQL mutations are here!

We introduced the newest version of the GraphQL wire adapter (lightning/graphql) in Spring ‘26. Now we’re introducing support for using GraphQL beyond just querying in LWC, adding the ability to easily create, update, and delete records via the GraphQL Mutations API.

Executing GraphQL mutations in LWC with executeMutation

In LWC, interacting with the Salesforce GraphQL API for mutations is achieved via the executeMutation function from the lightning/graphql module.
The executeMutation function allows you to execute one or more data changes. The function accepts an object parameter with the same three properties as the GraphQL wire: query, variables, and operationName. For example, to update an Account’s name:

1import { gql, executeMutation } from 'lightning/graphql';
2
3const updateRecord = gql(`
4            mutation UpdateAccount($input: AccountUpdateInput!) {
5                uiapi {
6                    AccountUpdate(input: $input) {
7                        success
8                    }
9                }
10            }
11`);
12
13 await executeMutation({
14            query: updateRecord,
15            variables: {
16                input: {
17                    Id: '001xx000003GYiCAAW',
18                    Account: {
19                        Name: 'Acme[Updated]',
20                    },
21                },
22            },
23        });

The executeMutation function supports dynamic query creation, just like the updated GraphQL support provided by lightning/graphql, so you can build these mutation inputs dynamically with JavaScript.

Data consistency considerations

Lightning Data Service keeps Salesforce record data consistent across UIAPI and GraphQL. With GraphQL mutations, this mostly works seamlessly, but we do have a few tips for getting the best results: 

  • Newly created records will not appear in existing GraphQL query results until the query is refreshed, depending on its filter criteria and cache state. This applies to create and update mutations that affect records included in a query result set. 
  • Updated record fields may be propagated to subscribed Lightning Data Service wire adapters when their cached data overlaps. It may not be necessary to refresh in all scenarios.
  • Deleted records will properly be removed from Lightning Data Service wire results. Refreshes are not required for delete operations.

See it in action: The LWC recipes showcase

To help you get started immediately, we have added dedicated examples to the LWC Recipes GitHub repository.

The new graphqlMutation components demonstrate how to use executeMutation to handle create, update, and delete operations through GraphQL. By exploring the source code for the graphqlMutation components, you can see practical implementations of data mutation, success handling, and error display via toast events.

You can clone the LWC Recipes repository to your local machine and deploy the app to your Salesforce org to test this new functionality.

GraphQL Mutations fully unlock bulk updates and tree saves for Lightning Web Components (LWC) without custom Apex. You can now not only view your Salesforce data efficiently but also modify it seamlessly, bringing richer, data-driven applications to life. This capability significantly streamlines the development of complex UIs that require simultaneous creation, update, or deletion of multiple related records. The integration of GraphQL Mutations marks a major step toward empowering LWC developers with a more modern and powerful way to manage data transactions on the Salesforce platform.

Developer Resources

Ready to start mutating your data? Here are the resources you need to dive in:

About the Authors

Stephen Carraway is a Lead Member of Technical Staff at Salesforce from the Lightning Data Service team. When he’s not building client data libraries, he’s busy woodworking, gardening, and 3D printing. 

Ben Sklar is a Director of Product Management at Salesforce responsible for UI API, the Salesforce GraphQL API, the Lightning Data Service, and AI Developer Kit. Ben is a major fan of GraphQL, but when not using GraphQL, you can find him playing ultimate frisbee or skiing during the winter. Follow him on LinkedIn.

More Blog Posts

The Salesforce Developer’s Guide to the Winter ’25 Release

The Salesforce Developer’s Guide to the Winter ’25 Release

The Winter '25 release is here! In this post, we highlight what’s new for developers across the Salesforce ecosystem.September 03, 2024

The Salesforce Developer’s Guide to the Winter ’26 Release

The Salesforce Developer’s Guide to the Winter ’26 Release

Learn about highlights for developers in the Winter '26 release across Lightning Web Components, Apex, Salesforce Platform developer tools, APIs, and more.September 08, 2025

Introducing the New Lightning Component Reference

Introducing the New Lightning Component Reference

Our new Lightning Component Reference is a complete, consistent documentation hub designed to empower developers with new source of trusted LWC content.November 05, 2025