Skip to content

GraphQL returns null address if optional telephone is set as empty string #30218

Closed
@Magepim

Description

@Magepim

Preconditions (*)

  1. Version 2.4.0 and 2.4-develop

Steps to reproduce (*)

1.Configure Magento address settings to have telephone number as optional.
2. Using GraphQL add a billing address to a quote using an empty string as the telephone value
3. Execute cart query via GraphQL. Billing address will return as 'null'

Expected result (*)

  1. Billing address expected to return in GraphQL response with full address details shown

Actual result (*)

  1. billing address returns as null.
  2. This is caused because the telephone field in the CartAddressInput in the GraphQL schema is marked as non-nullable. Magento saved the telephone value as null in the quote address when it is passed an empty string. The address is then validated against the schema when the response is being prepared and fails the schema validation.

Additional info from Engcom

Steps to reproduce

  1. From Admin, go to Stores - Configuration - Customer - Customer Configuration - Name and Address Options. Set Show Telephone to Optional
    show_telephone
  2. Using GraphQL mutation, add a product to Cart
  3. Set Billing Address on cart using the following Mutation
mutation {
  setBillingAddressOnCart(
    input: {
      cart_id: "YOrpn8PaE1sNO88W4KTqGlMu1UB6Rpoh"
      billing_address: {
        address: {
          firstname: "Bob"
          lastname: "Roll"
          company: "Magento"
          street: [
            "Magento Pkwy"
            "Main Street"
          ]
          city: "Austin"
          region: "TX"
          postcode: "78758"
          telephone: ""        #<---- note that the telephone is an empty string. 
          country_code: "US"
          save_in_address_book: true
        }
        same_as_shipping: false
      }
    }
  ) {
    cart {
      billing_address {
        firstname
        lastname
        company
        street
        city
        region {
          code
          label
        }
        postcode
        telephone
        country {
          code
          label
        }
      }
    }
  }
}
  1. Query Cart
query{
  cart(cart_id: "YOrpn8PaE1sNO88W4KTqGlMu1UB6Rpoh"){
    billing_address{
      city
      firstname
      lastname
      telephone
      region{
        code
      }
      street
    }
    items{
      id
      quantity
      product{
        name
      }
    }
  }
}

Actual Result
Cart query displayed Billing Adress as null

{
  "data": {
    "cart": {
      "billing_address": null,
      "items": [
        {
          "id": "1",
          "quantity": 3,
          "product": {
            "name": "Sproduct"
          }
        }
      ]
    }
  }
}

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • [X ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Component: CustomerGraphQlComponent: SalesGraphQlEvent: dmcdindia2020Issue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReported on 2.4.0Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S2Major restrictions or short-term circumventions are required until a fix is available.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions