updateCustomerEmail
Update customer email
Signature
declare function updateCustomerEmail(
context: Context,
input: MutationUpdateCustomerEmailArgs,
customQuery?: CustomQuery,
customHeaders?: CustomHeaders
): Promise<FetchResult<UpdateCustomerEmailMutation>>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
context | Required | Context | |
input | Required | MutationUpdateCustomerEmailArgs | |
customQuery | Optional | CustomQuery | |
customHeaders | Optional | CustomHeaders |
Referenced Types
- Context
- MutationUpdateCustomerEmailArgs
- CustomQuery
- CustomHeaders
FetchResultUpdateCustomerEmailMutation
Examples
Simple usage:
import { sdk } from '~/sdk.config.ts';
// update customer
const result = await sdk.magento.updateCustomerEmail({ email: "johndoe@example.com", password: "hunter2" });Creating a custom GraphQL query for updating customer
module.exports = {
integrations: {
magento: {
customQueries: {
'update-customer-email-custom-query': ({ variables, metadata }) => ({
variables,
query: `
mutation updateCustomerEmail($email: String!, $password: String!) {
updateCustomerEmail(email: $email, password: $password){
customer {
${metadata.fields}
}
}
}
`
}),
},
}
}
};Using a custom GraphQL query to update customer
import { sdk } from '~/sdk.config.ts';
// reduce the amount of fields returned by the query, when compared to the default query
const customQuery = {
updateCustomerEmail: 'update-customer-email-custom-query',
metadata: {
fields: 'email firstname'
}
};
const result = await sdk.magento.updateCustomerEmail({ email: "johndoe@example.com", password: "hunter2" }, customQuery);
// Result will contain only the fields specified in the custom query.