changeCustomerPassword
Change customer password.
Signature
declare function changeCustomerPassword(
context: Context,
params: {
currentPassword: string;
newPassword: string;
},
customQuery?: CustomQuery,
customHeaders?: CustomHeaders
): Promise<FetchResult<ChangeCustomerPasswordMutation>>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
context | Required | Context | |
params | Required | { currentPassword: string; newPassword: string; } | |
customQuery | Optional | CustomQuery | |
customHeaders | Optional | CustomHeaders |
Referenced Types
- Context
- CustomQuery
- CustomHeaders
FetchResultChangeCustomerPasswordMutation
Examples
Simple usage, change customer password:
import { sdk } from '~/sdk.config.ts';
const result = await sdk.magento.changeCustomerPassword({
currentPassword: 'currentPassword',
newPassword: 'newPassword'
});Creating a custom GraphQL query for changeCustomerPassword:
module.exports = {
integrations: {
magento: {
customQueries: {
'change-customer-password-custom-query': ({ variables, metadata }) => ({
variables,
query: `
mutation changeCustomerPassword($currentPassword: String!, $newPassword: String!) {
changeCustomerPassword(
currentPassword: $currentPassword
newPassword: $newPassword
) {
${metadata.fields}
}
}
`
}),
},
}
}
};Using a custom GraphQL query to narrow down the response data:
import { sdk } from '~/sdk.config.ts';
// reduce the amount of fields returned by the query, when compared to the default query
const customQuery = {
changeCustomerPassword: 'change-customer-password-custom-query',
metadata: {
fields: 'email'
}
};
const result = await sdk.magento.changeCustomerPassword({
currentPassword: 'currentPassword',
newPassword: 'newPassword'
}, customQuery);