magento / graphql-ce

[ARCHIVED] Please use magento/magento2 project
https://github.com/magento/magento2
Open Software License 3.0
131 stars 155 forks source link

Return original date_time instead of formatted stamp #1026

Closed janssentwh closed 5 years ago

janssentwh commented 5 years ago

As the date and time type customizable options still return an error in graphQL I have limited the scope of this solution to the sole purpose of returning the original date_time value.

Description (*)

As the date and time type customizable options still return an error in graphQL I have limited the scope of this solution to the sole purpose of returning the original date_time value.

Fixed Issues (if relevant)

  1. https://github.com/magento/graphql-ce/issues/1000: Date, time and date&time customizable options should havу the same format in output and input

Manual testing scenarios (*)

  1. Add a product to cart with GraphQL that has a customizable option of type date_time.
  2. See if the returned object contains the exact same stamp.

Questions or comments

I have not had the feeling this was the correct location of solving the problem as the Resolver might not to be concerned with the format of the output. I would like some feedback on this solution.

Contribution checklist (*)

TomashKhamlai commented 5 years ago

@janssentwh, thank you for your contribution. I would like to ask you to merge the latest changes from the mainline. PR#804 was merged yesterday and it is very important for us to test your code with the latest changes in 2.3-develop.

Today I had some trouble with this PR. Please try these steps and tell me if you are able to reproduce them.

Preconditions:

  1. Have a product with Date, Date&Time, Time customizable options.
  2. Registered customer.

Steps to reproduce:

  1. Create a customer token (GraphQL)
  2. Create empty cart using Bearer in the headers (GraphQL)
  3. Add product to cart (GraphQL)
  4. Go to Storefront
  5. Log in as a Customer
  6. Remove the item from the shopping cart
  7. Add product to cart (GraphQL)

    mutation {
    addSimpleProductsToCart(
    input: {
      cart_id: "12345678901234567890123456789012"
      cart_items: {
        data: {
          quantity: 1
          sku: "simple-product-1"
        }
        customizable_options: [
          {
            id: 3
            value_string: "01-01-01 14:00:05"
          }
                    {
            id: 1
            value_string: "01-01-01 14:00:05"
          }
          {
            id: 2
            value_string: "01-01-01 14:00:05"
          }
    
        ]
      }
    }
    ) {
    cart {
      items {
        id
        quantity
        product {
          sku
          stock_status
        }
        ... on SimpleCartItem {
          customizable_options {
            id
            label
            values {
              id
              label
              value
            }
          }
        }
      }
    }
    }
    }

Expected result:

  1. Validation if I am doing something wrong
  2. Product was added to the shopping cart otherwise

Actual result:

{
  "errors": [
    {
      "debugMessage": "Cannot return null for non-nullable field SelectedCustomizableOptionValue.value.",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 18,
          "column": 15
        }
      ],
      "path": [
        "addSimpleProductsToCart",
        "cart",
        "items",
        0,
        "customizable_options",
        1,
        "values",
        0,
        "value"
      ]
    }
  ],
  "data": {
    "addSimpleProductsToCart": {
      "cart": {
        "items": [
          {
            "id": "5",
            "quantity": 1,
            "product": {
              "sku": "simple-product-1",
              "stock_status": "IN_STOCK"
            },
            "customizable_options": [
              {
                "id": 1,
                "label": "d1",
                "values": [
                  {
                    "id": 19,
                    "label": "",
                    "value": "Jan 1, 2001"
                  }
                ]
              },
              {
                "id": 2,
                "label": "d2",
                "values": [
                  null
                ]
              },
              {
                "id": 3,
                "label": "d3",
                "values": [
                  {
                    "id": 21,
                    "label": "",
                    "value": "2:00 AM"
                  }
                ]
              }
            ]
          }
        ]
      }
    }
  }
}
TomashKhamlai commented 5 years ago

And please write some api-functional tests.

lenaorobei commented 5 years ago

Closing this PR due to inactivity. Please feel free to reopen if you would like to continue working on it. Thanks.

ghost commented 5 years ago

Hi @janssentwh, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.