Skip to content

Commit 906aeb2

Browse files
committed
added customer input fields doc block, changed try catch block for handling only validation exceptions
1 parent 9bf12cc commit 906aeb2

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818
use Magento\Framework\Exception\NoSuchEntityException;
1919
use Magento\Framework\GraphQl\Config\Element\Field;
2020
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
21+
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
22+
use Magento\Framework\GraphQl\Query\Resolver\Value;
2123
use Magento\Framework\GraphQl\Query\ResolverInterface;
2224
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
25+
use Magento\Framework\Validator\Exception as ValidatorException;
2326
use Magento\Newsletter\Model\SubscriberFactory;
2427
use Magento\Store\Model\StoreManagerInterface;
2528

@@ -82,7 +85,15 @@ public function __construct(
8285
}
8386

8487
/**
85-
* @inheritdoc
88+
* @param Field $field
89+
* @param ContextInterface $context
90+
* @param ResolveInfo $info
91+
* @param array|null $value
92+
* @param array|null $args
93+
* @return array|Value|mixed
94+
* @throws GraphQlInputException
95+
* @throws LocalizedException
96+
* @throws NoSuchEntityException
8697
*/
8798
public function resolve(
8899
Field $field,
@@ -104,7 +115,7 @@ public function resolve(
104115
}
105116
}
106117
$data = $this->customerDataProvider->getCustomerById($customerId);
107-
} catch (LocalizedException $e) {
118+
} catch (ValidatorException $e) {
108119
throw new GraphQlInputException(__($e->getMessage()));
109120
}
110121

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ type CustomerToken {
1818
}
1919

2020
input CustomerInput {
21-
prefix: String
22-
firstname: String
23-
middlename: String
24-
lastname: String
25-
suffix: String
26-
dob: String
27-
taxvat: String
28-
gender: Int
29-
email: String
30-
password: String
31-
is_subscribed: Boolean
21+
prefix: String @doc(description: "An honorific, such as Dr., Mr., or Mrs.")
22+
firstname: String @doc(description: "The customer's first name")
23+
middlename: String @doc(description: "The customer's middle name")
24+
lastname: String @doc(description: "The customer's family name")
25+
suffix: String @doc(description: "A value such as Sr., Jr., or III")
26+
email: String @doc(description: "The customer's email address. Required")
27+
dob: String @doc(description: "The customer's date of birth")
28+
taxvat: String @doc(description: "The customer's Tax/VAT number (for corporate customers)")
29+
gender: Int @doc(description: "The customer's gender(Male - 1, Female - 2)")
30+
password: String @doc(description: "The customer's password")
31+
is_subscribed: Boolean @doc(description: "Indicates whether the customer is subscribed to the company's newsletter")
3232
}
3333

3434
type CustomerOutput {

0 commit comments

Comments
 (0)