I am using Magento GraphQL api in my project. To create a customer address I used createCustomerAddress
mutation(createCustomerAddress).
Below is the mutation that I have called to create the customer address :
mutation createAddress {
createCustomerAddress(
input: {
firstname: "test"
lastname: "name"
company: "networld"
telephone: "1231231231"
street: ["test address line 1", "test address line 2"]
city: "Rajkot"
region: { region:"Gujarat", region_code: "GJ" }
postcode: "360001"
country_code: IN
}
) {
id
prefix
firstname
lastname
middlename
city
company
country_code
default_billing
default_shipping
postcode
region {
region
region_code
}
street
suffix
telephone
vat_id
}
}
This is working properly and returning me the result as below :
{
"data": {
"createCustomerAddress": {
"id": 44,
"prefix": null,
"firstname": "test",
"lastname": "name",
"middlename": null,
"city": "Rajkot",
"company": "networld",
"country_code": "IN",
"default_billing": false,
"default_shipping": false,
"postcode": "360001",
"region": {
"region": "Gujarat",
"region_code": "GJ"
},
"street": [
"test address line 1",
"test address line 2"
],
"suffix": null,
"telephone": "1231231231",
"vat_id": null
}
}
}
But, now when I query to get the customer address, it returning wrong region_code
.
Here is the query I written to get the customer address :
query{
customer{
addresses{
id
firstname
lastname
street
city
region{
region
region_code
}
country_code
postcode
telephone
}
}
}
Result :
{
"data": {
"customer": {
"addresses": [
{
"id": 44,
"firstname": "test",
"lastname": "name",
"street": [
"test address line 1",
"test address line 2"
],
"city": "Rajkot",
"region": {
"region": "Gujarat",
"region_code": "Gujarat"
},
"country_code": "IN",
"postcode": "360001",
"telephone": "1231231231"
}
]
}
}
}
As you can see, region_code
in this query result and region_code
in mutation result was different. Query not returning region_code
that generated from the mutation. Mutation generated region_code
was GJ and query returned region_code
was Gujarat.
Can anyone help me why this is happening ? How to solve it ?