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 Winter ‘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:

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.