{"id":12499,"date":"2026-03-11T07:31:50","date_gmt":"2026-03-11T07:31:50","guid":{"rendered":"https:\/\/www.greytrix.com\/blogs\/salesforce\/?p=12499"},"modified":"2026-03-06T07:34:12","modified_gmt":"2026-03-06T07:34:12","slug":"salesforce-spring-26-how-to-use-graphql-mutations-in-lightning-web-components-lwc","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/salesforce\/2026\/03\/11\/salesforce-spring-26-how-to-use-graphql-mutations-in-lightning-web-components-lwc\/","title":{"rendered":"Salesforce Spring \u201926: How to Use GraphQL Mutations in Lightning Web Components (LWC)"},"content":{"rendered":"\n<p>Salesforce Spring \u201926 introduces an exciting new capability for Lightning Web Components (LWC): GraphQL Mutations.<\/p>\n\n\n\n<p>If you\u2019ve been using LWC to display data, you\u2019re likely familiar with <strong>@wire(graphql)<\/strong>, which allows you to read data reactively. However, until now, creating, updating, or deleting records required Apex methods or REST API calls.<\/p>\n\n\n\n<p>With <strong>GraphQL mutations<\/strong>, developers can now perform create, update, and delete operations directly from JavaScript in LWC, making data operations simpler and more efficient.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">What Is a GraphQL Mutation?<\/mark><\/strong><\/h2>\n\n\n\n<p>In simple terms:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Query \u2192 Reads data<\/strong><\/li>\n\n\n\n<li><strong>Mutation \u2192 Creates, updates, or deletes data<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Think of it like this:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Queries = \u201cGive me this data\u201d<\/strong><\/li>\n\n\n\n<li><strong>Mutations = \u201cChange this data\u201d<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Salesforce Spring \u201926 introduces a new function called executeMutation, which allows developers to perform these operations directly within Lightning Web Components.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">How GraphQL Mutations Work in LWC<\/mark><\/strong><\/h2>\n\n\n\n<p>To use GraphQL mutations in LWC:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Define your mutation using the <strong>gql template<\/strong>.<\/li>\n\n\n\n<li>Send it using <strong>executeMutation<\/strong>, along with the required values.<\/li>\n\n\n\n<li>Retrieve only the fields you request &#8211; avoiding unnecessary data.<\/li>\n<\/ol>\n\n\n\n<p>This approach improves performance, efficiency, and developer productivity.<\/p>\n\n\n\n<p><strong>Step 1 &#8211;  Import the Required Functions<\/strong><\/p>\n\n\n\n<p>First, import the required functions:<\/p>\n\n\n\n<p>import { gql, executeMutation } from &#8216;lightning\/graphql&#8217;;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>gql<\/strong> allows you to write GraphQL queries or mutations.<\/li>\n\n\n\n<li><strong>executeMutation<\/strong> executes the mutation directly from your component.<\/li>\n<\/ul>\n\n\n\n<p><strong>Step 2 &#8211; Write a Simple Mutation<\/strong><\/p>\n\n\n\n<p>Here is an example of a GraphQL mutation to create a new Contact record.<\/p>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2026\/03\/1.-Simple-Mutation.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; align: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2026\/03\/1.-Simple-Mutation.png\" alt=\"Simple Mutation\"><\/a><\/center><font size=\"2\"><center><i>Simple Mutation<\/i><\/center><\/font>\n\n\n\n<p><strong>Explanation<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>$input<\/strong> represents the data we send to create the Contact.<\/li>\n\n\n\n<li>Record { Id, FirstName { value }, LastName { value } } specifies which fields we want Salesforce to return after the record is created.<\/li>\n<\/ul>\n\n\n\n<p>This ensures the response includes only the necessary fields.<\/p>\n\n\n\n<p><strong>Step 3 &#8211; Execute the Mutation<\/strong><\/p>\n\n\n\n<p>const result = await executeMutation({<br>    query: CREATE_CONTACT,<br>    variables: {<br>        input: {<br>            Contact: {<br>                FirstName: &#8216;Sam&#8217;,<br>                LastName: &#8216;Smith&#8217;<br>            }<br>        }<br>    }<br>});const newId = result.data.uiapi.ContactCreate.Record.Id;<br>console.log(&#8216;Created Contact ID:&#8217;, newId);<\/p>\n\n\n\n<p><strong>What Happens Here<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>We call executeMutation with the mutation query and variables.<\/li>\n\n\n\n<li>Salesforce creates the Contact record.<\/li>\n\n\n\n<li>The response returns the Contact ID, which can then be used inside the component.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">Beginner-Friendly Example<\/mark><\/strong><\/h2>\n\n\n\n<p>Imagine you have a form in your Lightning Web Component that allows users to create a new Contact.<\/p>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2026\/03\/2.-ContactFormhtml.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; align: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2026\/03\/2.-ContactFormhtml.png\" alt=\"ContactForm.html\"><\/a><\/center><font size=\"2\"><center><i>ContactForm.html<\/i><\/center><\/font>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2026\/03\/3.-ConatctFormjs.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; align: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2026\/03\/3.-ConatctFormjs.png\" alt=\"ContacttForm.js\"><\/a><\/center><font size=\"2\"><center><i>ContactForm.js<\/i><\/center><\/font>\n\n\n\n<p>Using <strong>GraphQL mutations<\/strong>, users can submit the form and instantly create a <strong>Contact record<\/strong>, all handled directly within <strong>LWC using GraphQL<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">Conclusion<\/mark><\/strong><\/h2>\n\n\n\n<p>GraphQL Mutations in Lightning Web Components introduce a modern and efficient way to perform create, update, and delete operations directly from LWC. With the Spring \u201926 release, developers can now manage data operations using GraphQL without relying heavily on Apex or REST APIs. By using executeMutation, LWC components become more streamlined, flexible, and easier to maintain. This enhancement helps developers build faster, cleaner, and more scalable Salesforce applications while simplifying client-side data management.<\/p>\n\n\n\n<p>By following the above blog instructions, you will be able to learn <strong>\u201cSalesforce Spring \u201926: How to Use GraphQL Mutations in Lightning Web Components (LWC)\u201c<\/strong>. If you still have queries or any related problems, don\u2019t hesitate to contact us at <a href=\"mailto:salesforce@greytrix.com\" target=\"_blank\" rel=\"noreferrer noopener\">salesforce@greytrix.com<\/a>. More details about our integration product are available on <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/\" target=\"_blank\" rel=\"noreferrer noopener\">our website<\/a> and <a href=\"https:\/\/appexchange.salesforce.com\/appxListingDetail?listingId=a0N30000000psM5EAI\" target=\"_blank\" rel=\"noreferrer noopener\">Salesforce AppExchange<\/a>.<\/p>\n\n\n\n<p>We hope you may find this blog resourceful and helpful. However, if you still have concerns and need more help, please contact us at <a href=\"mailto:salesforce@greytrix.com\" target=\"_blank\" rel=\"noreferrer noopener\">salesforce@greytrix.com<\/a>.<\/p>\n\n\n\n<p style=\"text-align: justify\"><b>About Us<\/b><\/br>\n<p><a href=\"https:\/\/www.greytrix.com\/\">Greytrix<\/a> \u2013 a globally recognized and one of the oldest Sage Development Partner and a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners and Sage PSG across the globe. We offer Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that require apex code incorporation into the Salesforce platform.<br><br> Greytrix has some unique solutions for Cloud CRM such as <a href=\"\">Salesforce Sage integration<\/a> for <a href=\"https:\/\/www.greytrix.com\/sage-x3-erp\/integration\/\">Sage X3<\/a>, <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/sage-100-integration\/\">Sage 100<\/a> and <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/sage-300-integration\/\">Sage 300 (Sage Accpac)<\/a>. We also offer best-in-class Cloud CRM <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/crm-development\/\">Salesforce customization and development services<\/a> along with services such as Salesforce <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/data-migration-support\/\">Data Migration<\/a>, <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/crm-development\/\">Integrated App development<\/a>, Custom App development and Technical Support business partners and end users. Salesforce Cloud CRM integration offered by Greytrix works with Lightning web components and supports standard opportunity workflow. Greytrix GUMU&#x2122; integration for Sage ERP \u2013 Salesforce is a 5-star rated app listed on <a href=\"https:\/\/appexchange.salesforce.com\/appxListingDetail?listingId=a0N30000000psM5EAI\" target=\"_blank\" rel=\"noopener\">Salesforce AppExchange<\/a>.<br> The GUMU&#x2122; Cloud framework by Greytrix forms the backbone of cloud integrations that are managed in real-time for processing and execution of application programs at the click of a button.<br><br> For more information on our Salesforce products and services, contact us at <a href=\"mailto:salesforce@greytrix.com\">salesforce@greytrix.com<\/a>. We will be glad to assist you.<\/p>\n\n\n\n<p><strong>Related Posts<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2022\/01\/31\/how-to-call-the-apex-method-in-lightning-web-component\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to call the apex method in lightning web component<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/09\/22\/how-to-use-email-template-in-apex-code\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Use Email Template in Apex Code<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/08\/16\/clone-record-of-any-object-using-flows-in-salesforce\/\" target=\"_blank\" rel=\"noreferrer noopener\">Clone Record of Any Object using Flows in Salesforce<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/08\/14\/how-to-avoid-null-pointer-exception-by-using-safe-navigator-operator\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Avoid Null Pointer Exception By Using Safe Navigator<\/a> <a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/08\/14\/how-to-avoid-null-pointer-exception-by-using-safe-navigator-operator\/\">Operator (?.)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/08\/17\/how-to-create-a-dynamic-multi-filter-object-in-salesforce-part-i\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to create a dynamic multi-filter object in Salesforce-<\/a> <a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/08\/17\/how-to-create-a-dynamic-multi-filter-object-in-salesforce-part-i\/\">Part I<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Salesforce Spring \u201926 introduces an exciting new capability for Lightning Web Components (LWC): GraphQL Mutations. If you\u2019ve been using LWC to display data, you\u2019re likely familiar with @wire(graphql), which allows you to read data reactively. However, until now, creating, updating, or deleting records required Apex methods or REST API calls. With GraphQL mutations, developers can\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2026\/03\/11\/salesforce-spring-26-how-to-use-graphql-mutations-in-lightning-web-components-lwc\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[2959,2957,2955,2965,2956,2943,2952,2948,2961,2950,2954,2940,2947,2962,2941,2969,2963,2964,2966,2949,2942,2945,2958,2967,2970,2951,2968,2946,2815,2939,2953,2944,2971,2960],"class_list":["post-12499","post","type-post","status-publish","format-standard","hentry","category-salesforce-srv","tag-create-records-with-graphql-lwc","tag-delete-records-using-graphql-lwc","tag-executemutation-in-lwc","tag-graphql-crud-operations-salesforce","tag-graphql-in-salesforce-ui-api","tag-graphql-mutation-in-lwc","tag-graphql-mutations-in-lwc","tag-graphql-operations-in-salesforce-lwc","tag-graphql-vs-apex-in-salesforce","tag-lightning-web-component-graphql-tutorial","tag-lightning-web-components-graphql","tag-lightning-web-components-graphql-tutorial","tag-lwc-create-contact-using-graphql","tag-lwc-data-operations-without-apex","tag-lwc-graphql-create-record","tag-lwc-graphql-implementation","tag-lwc-graphql-integration-guide","tag-modern-data-handling-in-lwc","tag-reactive-data-in-lightning-web-components","tag-salesforce-developer-graphql-guide","tag-salesforce-executemutation-example","tag-salesforce-graphql-api-mutation-example","tag-salesforce-graphql-api-tutorial","tag-salesforce-graphql-best-practices","tag-salesforce-graphql-javascript-example","tag-salesforce-graphql-mutation-example","tag-salesforce-lwc-data-management","tag-salesforce-spring-26-developer-features-2","tag-salesforce-spring-26-developer-features","tag-salesforce-spring-26-graphql-mutations","tag-salesforce-spring-26-lwc-features","tag-salesforce-ui-api-graphql-mutation","tag-salesforce-ui-api-mutation-example","tag-update-records-with-graphql-salesforce"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/12499","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/comments?post=12499"}],"version-history":[{"count":9,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/12499\/revisions"}],"predecessor-version":[{"id":12542,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/12499\/revisions\/12542"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/media?parent=12499"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/categories?post=12499"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/tags?post=12499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}