Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Postcode is not listed in the array of errors #1029

Closed
TomashKhamlai opened this issue Oct 24, 2019 · 3 comments
Closed

Postcode is not listed in the array of errors #1029

TomashKhamlai opened this issue Oct 24, 2019 · 3 comments
Assignees

Comments

@TomashKhamlai
Copy link
Contributor

Preconditions (*)

No preconditions

Steps to reproduce (*)

  1. Perform mutation as a Customer
mutation {
    createCustomerAddress(
      input: {
        country_id: AF
        #country_code: "AF"
        city: "1"
        firstname: "2"
        lastname: "3"
      }
    ) {
      country_id
      #country_code
      city
      firstname
      lastname
    }
  }

Expected result (*)

{
  "errors": [
    {
      "message": "Required parameters are missing: street, telephone, postcode",
      "extensions": {
        "category": "graphql-input"
      },
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "createCustomerAddress"
      ]
    }
  ],
  "data": {
    "createCustomerAddress": null
  }
}

Actual result (*)

{
  "errors": [
    {
      "message": "Required parameters are missing: street, telephone",
      "extensions": {
        "category": "graphql-input"
      },
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "createCustomerAddress"
      ]
    }
  ],
  "data": {
    "createCustomerAddress": null
  }
}
@osrecio
Copy link
Member

osrecio commented Oct 27, 2019

I checked this issue but:

The postcode in the table eav_attribute the column is_required is set to 0.

The implementation on the file: \Magento\CustomerGraphQl\Model\Customer\Address\CreateCustomerAddress::validateData

foreach ($attributes as $attributeName => $attributeInfo) {
            if ($attributeInfo->getIsRequired()
                && (!isset($addressData[$attributeName]) || empty($addressData[$attributeName]))
            ) {
                $errorInput[] = $attributeName;
            }
        }

if the postcode field is not required, so I think the behaviour is ok.

We have 2 options:

  1. Add is_required in table eav_attribute. This can be a problem... for BC and the other implementations.
  2. Add to validate data something like:
foreach ($attributes as $attributeName => $attributeInfo) {
            if (($attrtibuteName == 'postcode' && && (!isset($addressData[$attributeName]) || empty($addressData[$attributeName])) || $attributeInfo->getIsRequired()
                && (!isset($addressData[$attributeName]) || empty($addressData[$attributeName]))
            ) {
                $errorInput[] = $attributeName;
            }
        } 

@osrecio
Copy link
Member

osrecio commented Oct 27, 2019

I saw the validation after save. Creating a PR

osrecio added a commit to osrecio/graphql-ce that referenced this issue Oct 27, 2019
osrecio added a commit to osrecio/graphql-ce that referenced this issue Oct 27, 2019
osrecio added a commit to osrecio/graphql-ce that referenced this issue Oct 27, 2019
osrecio added a commit to osrecio/graphql-ce that referenced this issue Oct 27, 2019
lenaorobei added a commit to osrecio/graphql-ce that referenced this issue Nov 8, 2019
@lenaorobei lenaorobei added this to the Release: 2.3.5 milestone Nov 13, 2019
@magento-engcom-team
Copy link
Contributor

Hi @TomashKhamlai. Thank you for your report.
The issue has been fixed in #1031 by @osrecio in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.5 release.

magento-engcom-team added a commit that referenced this issue Nov 14, 2019
…Mutation createCustomerAddress #1031

 - Merge Pull Request #1031 from osrecio/graphql-ce:1029-postcode-required-customerCreate
 - Merged commits:
   1. 676cd1b
   2. 127835e
   3. 891e5a4
magento-engcom-team pushed a commit that referenced this issue Nov 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants