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

GraphQL doesn't check that Region belongs to country where it is possible #1046

Closed
TomashKhamlai opened this issue Nov 1, 2019 · 3 comments
Labels
bug Something isn't working Component: QuoteGraphQl for-grooming This issue needs to be discussed before it can be worked on

Comments

@TomashKhamlai
Copy link
Contributor

Problem:

  1. In Canada, there is no California. Send request:
mutation {
  createCustomerAddress(
    input: {
      firstname: "Yes"
      lastname: "Yes"
      country_code: CA
      region: {
        region: "California"
      }
      postcode: "Yes"
      city: "Yes"
      street: "Yes"
      telephone: "Yes"
    }
  ) {
    firstname
    telephone
    region {
      region
      region_code
    }
    lastname
    country_code
    postcode
  }
}

Response:

{
  "data": {
    "createCustomerAddress": {
      "firstname": "Yes",
      "telephone": "Yes",
      "region": {
        "region": "California",
        "region_code": null
      },
      "lastname": "Yes",
      "country_code": "CA",
      "postcode": "Yes"
    }
  }
}
  1. Login as a Customer and check addresses in Address Book
    image
  2. Click Edit
    ❌ California is not selected
    image
  3. ❌ Modify Company and click "Save Address" button
    image

Proposed solution:

Use \Magento\Customer\Model\Address\Validator\Country::validate for this purpose.

@TomashKhamlai TomashKhamlai added Component: QuoteGraphQl for-grooming This issue needs to be discussed before it can be worked on labels Nov 1, 2019
@lenaorobei
Copy link
Contributor

@TomashKhamlai please check on latest 2.3-develop. It should be fixed.

@TomashKhamlai
Copy link
Contributor Author

@lenaorobei, no it is not fixed yet.

@lenaorobei lenaorobei added bug Something isn't working Progress: ready for dev labels Nov 13, 2019
@lenaorobei lenaorobei added the Event: cd19kharkiv Contribution Day 2019 Kharkiv label Nov 21, 2019
@lenaorobei lenaorobei removed the Event: cd19kharkiv Contribution Day 2019 Kharkiv label Dec 2, 2019
@atwixfirster
Copy link
Contributor

Unable to reproduce.

Steps taken:
1. Create an empty cart:

mutation {
  createEmptyCart
}

2. Add product into cart:

mutation {  
  addSimpleProductsToCart(
    input: {
      cart_id: "hnnNHI6X7a3N6cdbmoeswrF3qewwHQqC"
      cart_items: [
        {
          data: {
            quantity: 1
            sku: "xxx0001"
          }
        }
      ]
    }
  ) {
    cart {
      items {
        id
        product {
          sku
          stock_status
        }
        quantity
      }
    }
  }
}

3. Set shipping address:

mutation {
  setShippingAddressesOnCart(
    input: {
      cart_id: "hnnNHI6X7a3N6cdbmoeswrF3qewwHQqC"
      shipping_addresses: [
        {
          address: {
            firstname: "John"
            lastname: "Doe"
            company: "Company Name"
            street: ["320 N Crescent Dr", "Beverly Hills"]
            city: "Los Angeles"
            region: "CA"
            postcode: "90210"
            country_code: "CA"
            telephone: "123-456-0000"
            save_in_address_book: false
          }
        }
      ]
    }
  ) {
    cart {
      shipping_addresses {
        firstname
        lastname
        company
        street
        city
        region {
          code
          label
        }
        postcode
        telephone
        country {
          code
          label
        }
        
      }
    }
  }
}

Actual result: Region is not available for the selected country:

1046

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working Component: QuoteGraphQl for-grooming This issue needs to be discussed before it can be worked on
Projects
None yet
Development

No branches or pull requests

3 participants