reactioncommerce / example-storefront

Example Storefront is Reaction Commerce’s headless ecommerce storefront - Next.js, GraphQL, React. Built using Apollo Client and the commerce-focused React UI components provided in the Storefront Component Library (reactioncommerce/reaction-component-library). It connects with Reaction backend with the GraphQL API.
https://www.mailchimp.com/developer/open-commerce
Apache License 2.0
608 stars 288 forks source link

Order object doesn't have notes array #631

Closed karaarda closed 2 years ago

karaarda commented 5 years ago

Prerequisites

Issue Description

Order item doesn't contain "notes" property.

Steps to Reproduce

Please provide starting context, i.e. logged in as a user, configure a particular payment method.

  1. View ProfileOrders component
  2. Log this.props.logs

Possible Solution

Return empty array when notes doesn't exist as written in the documentation

According to the schema.graphql:

"Notes about the order. This will always return an array but it may be empty" notes: [OrderNote]!

Actual data returned:


[
  {
    "_id": "cmVhY3Rpb24vb3JkZXI6Rnd6OEVBcEhhREJva0xmVGI=",
    "account": {
      "_id": "cmVhY3Rpb24vYWNjb3VudDp0S2tBZVhIbnFvU2dKWmJZNA==",
      "__typename": "Account"
    },
    "cartId": "cmVhY3Rpb24vY2FydDpGd3o4RUFwSGFEQm9rTGZUYg==",
    "createdAt": "2019-09-28T14:23:35.323Z",
    "displayStatus": "new",
    "email": "name@example.com",
    "fulfillmentGroups": [
      {
        "_id": "cmVhY3Rpb24vb3JkZXJGdWxmaWxsbWVudEdyb3VwOnZLYkJkTnI0dUtqR0N1ZFAz",
        "data": {
          "shippingAddress": {
            "_id": null,
            "address1": "a",
            "address2": null,
            "city": "a",
            "company": null,
            "country": "a",
            "fullName": "a b",
            "isCommercial": false,
            "isShippingDefault": false,
            "phone": "1",
            "postal": "a",
            "region": "a",
            "__typename": "Address"
          },
          "__typename": "ShippingOrderFulfillmentGroupData"
        },
        "items": {
          "nodes": [
            {
              "_id": "cmVhY3Rpb24vb3JkZXJJdGVtOlltdzZzUENhZ2lSV2k4NVp3",
              "addedAt": "2019-09-28T14:23:24.339Z",
              "createdAt": "2019-09-28T14:23:35.273Z",
              "imageURLs": null,
              "isTaxable": true,
              "optionTitle": "With Logo",
              "parcel": null,
              "price": {
                "amount": 0,
                "currency": {
                  "code": "EUR",
                  "__typename": "Currency"
                },
                "displayAmount": "0,00 €",
                "__typename": "Money"
              },
              "productConfiguration": {
                "productId": "cmVhY3Rpb24vcHJvZHVjdDpaOTdwWHNDZE04ZzNoWE5Xdg==",
                "productVariantId": "cmVhY3Rpb24vcHJvZHVjdDpDM0xDR2MzYTVvQnh6UVFYcg==",
                "__typename": "ProductConfiguration"
              },
              "productSlug": "embnl43dbwr6s6lft",
              "productType": "product-simple",
              "productVendor": null,
              "productTags": {
                "nodes": [
                  {
                    "name": "Motion Overlay",
                    "__typename": "Tag"
                  }
                ],
                "__typename": "TagConnection"
              },
              "quantity": 1,
              "shop": {
                "_id": "cmVhY3Rpb24vc2hvcDpKOEJocTN1VHRkZ3daeDNyeg==",
                "__typename": "Shop"
              },
              "subtotal": {
                "amount": 0,
                "currency": {
                  "code": "EUR",
                  "__typename": "Currency"
                },
                "displayAmount": "0,00 €",
                "__typename": "Money"
              },
              "taxCode": null,
              "title": "firsteffect",
              "updatedAt": "2019-09-28T14:23:35.273Z",
              "variantTitle": "First Effect With Logo",
              "__typename": "OrderItem"
            }
          ],
          "__typename": "OrderItemConnection"
        },
        "selectedFulfillmentOption": {
          "fulfillmentMethod": {
            "_id": "cmVhY3Rpb24vZnVsZmlsbG1lbnRNZXRob2Q6WGQzV1lXUVpGN0pkMzNxWGk=",
            "carrier": "Flat Rate",
            "displayName": "free",
            "fulfillmentTypes": [
              "shipping"
            ],
            "group": "Free",
            "name": "free",
            "__typename": "FulfillmentMethod"
          },
          "handlingPrice": {
            "amount": 0,
            "currency": {
              "code": "EUR",
              "__typename": "Currency"
            },
            "displayAmount": "0,00 €",
            "__typename": "Money"
          },
          "price": {
            "amount": 0,
            "currency": {
              "code": "EUR",
              "__typename": "Currency"
            },
            "displayAmount": "0,00 €",
            "__typename": "Money"
          },
          "__typename": "FulfillmentOption"
        },
        "shop": {
          "_id": "cmVhY3Rpb24vc2hvcDpKOEJocTN1VHRkZ3daeDNyeg==",
          "__typename": "Shop"
        },
        "summary": {
          "fulfillmentTotal": {
            "amount": 0,
            "displayAmount": "0,00 €",
            "__typename": "Money"
          },
          "itemTotal": {
            "amount": 0,
            "displayAmount": "0,00 €",
            "__typename": "Money"
          },
          "surchargeTotal": {
            "amount": 0,
            "displayAmount": "0,00 €",
            "__typename": "Money"
          },
          "taxTotal": {
            "amount": 0,
            "displayAmount": "0,00 €",
            "__typename": "Money"
          },
          "total": {
            "amount": 0,
            "displayAmount": "0,00 €",
            "__typename": "Money"
          },
          "__typename": "OrderSummary"
        },
        "tracking": null,
        "type": "shipping",
        "__typename": "OrderFulfillmentGroup"
      }
    ],
    "payments": [],
    "referenceId": "dWhpSjHju8fER4vCx",
    "shop": {
      "_id": "cmVhY3Rpb24vc2hvcDpKOEJocTN1VHRkZ3daeDNyeg==",
      "currency": {
        "code": "EUR",
        "__typename": "Currency"
      },
      "__typename": "Shop"
    },
    "status": "new",
    "summary": {
      "fulfillmentTotal": {
        "amount": 0,
        "displayAmount": "0,00 €",
        "__typename": "Money"
      },
      "itemTotal": {
        "amount": 0,
        "displayAmount": "0,00 €",
        "__typename": "Money"
      },
      "surchargeTotal": {
        "amount": 0,
        "displayAmount": "0,00 €",
        "__typename": "Money"
      },
      "taxTotal": {
        "amount": 0,
        "displayAmount": "0,00 €",
        "__typename": "Money"
      },
      "total": {
        "amount": 0,
        "displayAmount": "0,00 €",
        "__typename": "Money"
      },
      "__typename": "OrderSummary"
    },
    "totalItemQuantity": 1,
    "updatedAt": "2019-09-28T14:23:35.323Z",
    "__typename": "Order"
  }
]
aldeed commented 4 years ago

Moved this from the API repo to the example storefront repo. The API docs are correct in that notes is always an array if you request it. The problem is that the storefront query does not request notes.

The fix is to add notes { } with some notes fields in the OrderCommon fragment definition in example-storefront codebase.