Posts

Showing posts with the label executeMutation

Salesforce Fact #969 | LWC GraphQL mutation with address field

Image
While creating records with address field using GraphQL mutation feature, we need to specify each of the constituting field values of the address. For country and state, the statecode and countrycode counterparts won't work. Example error: contains a field not in 'ContactCreateRepresentation': 'MailingCountryCode' And while fetching the data, we need to specify the constituent fields as the compound field won't work. Example error: Validation error (FieldUndefined@[uiapi/ContactCreate/Record/MailingAddress/value]) : Field 'value' in type 'Contact_MailingAddress_CompoundField' is undefined Attached is the screenshot of the correct syntax.

Salesforce Fact #967 | LWC GraphQLmutation with variables

Image
We can pass variables in the mutation operations in LWC GraphQL. In this example, we are passing the LastName, Email and Phone field values as variables in the Create Contact operation. Reference:  https://developer.salesforce.com/docs/platform/lwc/guide/reference-graphql-mutation.html Attached are the screenshots.

Salesforce Fact #965 | executeMutation in GraphQL

Image
In the upcoming Spring'26 release, we will be able to mutate data with the GraphQL api i.e. it will now be possible to perform create, update or delete operations. Also, using this api we will be able to create multiple related records in the single call, similar to composite api. In this example, we are creating an account and a related contact record. Reference:  https://developer.salesforce.com/docs/platform/graphql/guide/mutations-use.html https://developer.salesforce.com/docs/platform/lwc/guide/reference-graphql-mutation.html Attached are the screenshots.