Skip to content

Commit 828b0ab

Browse files
authored
LYNX-955: [AC-2.4.9] GraphQL API Customer ID value Deprecation Removal (#375)
* LYNX-955: [AC-2.4.9] GraphQL API Customer ID value Deprecation Removal * Test cases added * Tests fixed * Test cases updated * LYNX-955 feedbacks fixed * LYNX-955 Review feedback fixed * LYNX-955 review feedback fixed * Static tests fixed
1 parent 47dfa9f commit 828b0ab

File tree

11 files changed

+1468
-1074
lines changed

11 files changed

+1468
-1074
lines changed

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

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2017 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -12,6 +12,7 @@
1212
use Magento\Customer\Api\Data\CustomerInterface;
1313
use Magento\EavGraphQl\Model\GetAttributeValueComposite;
1414
use Magento\Framework\Exception\LocalizedException;
15+
use Magento\Framework\GraphQl\Query\Uid;
1516
use Magento\Framework\Webapi\ServiceOutputProcessor;
1617

1718
/**
@@ -20,25 +21,17 @@
2021
class ExtractCustomerData
2122
{
2223
/**
23-
* @var ServiceOutputProcessor
24-
*/
25-
private $serviceOutputProcessor;
26-
27-
/**
28-
* @var GetAttributeValueComposite
29-
*/
30-
private GetAttributeValueComposite $getAttributeValueComposite;
31-
32-
/**
24+
* ExtractCustomerData Constructor.
25+
*
3326
* @param ServiceOutputProcessor $serviceOutputProcessor
3427
* @param GetAttributeValueComposite $getAttributeValueComposite
28+
* @param Uid $idEncoder
3529
*/
3630
public function __construct(
37-
ServiceOutputProcessor $serviceOutputProcessor,
38-
GetAttributeValueComposite $getAttributeValueComposite
31+
private readonly ServiceOutputProcessor $serviceOutputProcessor,
32+
private readonly GetAttributeValueComposite $getAttributeValueComposite,
33+
private readonly Uid $idEncoder
3934
) {
40-
$this->serviceOutputProcessor = $serviceOutputProcessor;
41-
$this->getAttributeValueComposite = $getAttributeValueComposite;
4235
}
4336

4437
/**
@@ -57,6 +50,7 @@ private function curateAddressData(array $arrayAddress): array
5750
$arrayAddress[$key]['default_billing'] = false;
5851
}
5952
}
53+
6054
return $arrayAddress;
6155
}
6256

@@ -98,14 +92,15 @@ function (array $customAttribute) {
9892
}
9993
//Fields are deprecated and should not be exposed on storefront.
10094
$customerData['group_id'] = null;
101-
$customerData['id'] = null;
102-
10395
$customerData['model'] = $customer;
10496

10597
//'dob' is deprecated, 'date_of_birth' is used instead.
10698
if (!empty($customerData['dob'])) {
10799
$customerData['date_of_birth'] = $customerData['dob'];
108100
}
101+
102+
$customerData['id'] = $this->idEncoder->encode((string) $customerData['id']);
103+
109104
return $customerData;
110105
}
111106
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ type Customer @doc(description: "Defines the customer name, addresses, and other
147147
dob: String @doc(description: "The customer's date of birth.") @deprecated(reason: "Use `date_of_birth` instead.")
148148
date_of_birth: String @doc(description: "The customer's date of birth.")
149149
taxvat: String @doc(description: "The customer's Value-added tax (VAT) number (for corporate customers).")
150-
id: Int @doc(description: "The ID assigned to the customer.") @deprecated(reason: "`id` is not needed as part of `Customer`, because on the server side, it can be identified based on the customer token used for authentication. There is no need to know customer ID on the client side.")
150+
id: ID! @doc(description: "The unique ID assigned to the customer.")
151151
is_subscribed: Boolean @doc(description: "Indicates whether the customer is subscribed to the company's newsletter.") @resolver(class: "\\Magento\\NewsletterGraphQl\\Model\\Resolver\\IsSubscribed")
152152
addresses: [CustomerAddress] @doc(description: "An array containing the customer's shipping and billing addresses.") @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\CustomerAddresses")
153153
addressesV2(

0 commit comments

Comments
 (0)