Skip to content

Commit 9f0ae06

Browse files
authored
LYNX-121: Add custom_attributes to updateCustomerV2 mutation (#109)
1 parent ce8ace7 commit 9f0ae06

File tree

3 files changed

+383
-1
lines changed

3 files changed

+383
-1
lines changed

app/code/Magento/CustomerGraphQl/Model/Customer/UpdateCustomerAccount.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\CustomerGraphQl\Model\Customer;
99

1010
use Magento\Customer\Api\Data\CustomerInterface;
11+
use Magento\Framework\Exception\LocalizedException;
1112
use Magento\Framework\Exception\NoSuchEntityException;
1213
use Magento\Framework\GraphQl\Exception\GraphQlAlreadyExistsException;
1314
use Magento\Framework\GraphQl\Exception\GraphQlAuthenticationException;
@@ -89,17 +90,20 @@ public function __construct(
8990
* @throws GraphQlAuthenticationException
9091
* @throws GraphQlInputException
9192
* @throws GraphQlNoSuchEntityException
93+
* @throws NoSuchEntityException
94+
* @throws LocalizedException
9295
*/
9396
public function execute(CustomerInterface $customer, array $data, StoreInterface $store): void
9497
{
9598
if (isset($data['email']) && $customer->getEmail() !== $data['email']) {
96-
if (!isset($data['password']) || empty($data['password'])) {
99+
if (empty($data['password'])) {
97100
throw new GraphQlInputException(__('Provide the current "password" to change "email".'));
98101
}
99102

100103
$this->checkCustomerPassword->execute($data['password'], (int)$customer->getId());
101104
$customer->setEmail($data['email']);
102105
}
106+
103107
$this->validateCustomerData->execute($data);
104108
$filteredData = array_diff_key($data, array_flip($this->restrictedKeys));
105109
$this->dataObjectHelper->populateWithArray($customer, $filteredData, CustomerInterface::class);

app/code/Magento/CustomerGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ input CustomerUpdateInput @doc(description: "An input object for updating a cust
109109
prefix: String @doc(description: "An honorific, such as Dr., Mr., or Mrs.")
110110
suffix: String @doc(description: "A value such as Sr., Jr., or III.")
111111
taxvat: String @doc(description: "The customer's Tax/VAT number (for corporate customers).")
112+
custom_attributes: [AttributeValueInput!] @doc(description: "The customer's custom attributes.")
112113
}
113114

114115
type CustomerOutput @doc(description: "Contains details about a newly-created or updated customer.") {

0 commit comments

Comments
 (0)