Skip to content

Commit b72a5c6

Browse files
committed
magento/graphql-ce#961: ShippingAddressInput.postcode: String, is not required by Schema
1 parent 2e4cd74 commit b72a5c6

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\CustomerGraphQl\Model\Customer\Address\GetCustomerAddress;
1212
use Magento\Directory\Api\CountryInformationAcquirerInterface;
1313
use Magento\Framework\Exception\LocalizedException;
14+
use Magento\Framework\Exception\NoSuchEntityException;
1415
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
1516
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1617
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
@@ -58,7 +59,6 @@ public function __construct(
5859
$this->getCustomerAddress = $getCustomerAddress;
5960
$this->addressHelper = $addressHelper;
6061
$this->countryInformationAcquirer = $countryInformationAcquirer;
61-
$this->countryInformationAcquirer = $countryInformationAcquirer;
6262
}
6363

6464
/**
@@ -78,7 +78,11 @@ public function createBasedOnInputData(array $addressInput): QuoteAddress
7878
}
7979

8080
if ($addressInput['country_id'] && isset($addressInput['region'])) {
81-
$countryInformation = $this->countryInformationAcquirer->getCountryInfo($addressInput['country_id']);
81+
try {
82+
$countryInformation = $this->countryInformationAcquirer->getCountryInfo($addressInput['country_id']);
83+
} catch (NoSuchEntityException $e) {
84+
throw new GraphQlInputException(__('The country isn\'t available.'));
85+
}
8286
$availableRegions = $countryInformation->getAvailableRegions();
8387
if (null !== $availableRegions) {
8488
$addressInput['region_code'] = $addressInput['region'];

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ public function testSetNewBillingAddressWithSaveInAddressBook()
798798
company: "test company"
799799
street: ["test street 1", "test street 2"]
800800
city: "test city"
801-
region: "test region"
801+
region: "AZ"
802802
postcode: "887766"
803803
country_code: "US"
804804
telephone: "88776655"
@@ -865,7 +865,7 @@ public function testSetNewBillingAddressWithNotSaveInAddressBook()
865865
company: "test company"
866866
street: ["test street 1", "test street 2"]
867867
city: "test city"
868-
region: "test region"
868+
region: "AZ"
869869
postcode: "887766"
870870
country_code: "US"
871871
telephone: "88776655"
@@ -933,7 +933,7 @@ public function testWithInvalidBillingAddressInput()
933933
company: "test company"
934934
street: ["test street 1", "test street 2"]
935935
city: "test city"
936-
region: "test region"
936+
region: "AZ"
937937
postcode: "887766"
938938
country_code: "USS"
939939
telephone: "88776655"
@@ -960,7 +960,7 @@ public function testWithInvalidBillingAddressInput()
960960
}
961961
}
962962
QUERY;
963-
$this->expectExceptionMessage('The address failed to save. Verify the address and try again.');
963+
$this->expectExceptionMessage('The country isn\'t available.');
964964
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
965965
}
966966

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ public function testWithInvalidShippingAddressesInput()
780780
}
781781
}
782782
QUERY;
783-
$this->expectExceptionMessage('The address failed to save. Verify the address and try again.');
783+
$this->expectExceptionMessage('The country isn\'t available.');
784784
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
785785
}
786786

@@ -806,7 +806,7 @@ public function testSetNewShippingAddressWithSaveInAddressBook()
806806
company: "test company"
807807
street: ["test street 1", "test street 2"]
808808
city: "test city"
809-
region: "test region"
809+
region: "AZ"
810810
postcode: "887766"
811811
country_code: "US"
812812
telephone: "88776655"
@@ -877,7 +877,7 @@ public function testSetNewShippingAddressWithNotSaveInAddressBook()
877877
company: "test company"
878878
street: ["test street 1", "test street 2"]
879879
city: "test city"
880-
region: "test region"
880+
region: "AZ"
881881
postcode: "887766"
882882
country_code: "US"
883883
telephone: "88776655"

0 commit comments

Comments
 (0)