magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

ShipmentTracking.title shall not be non-nullable

Open jbruni opened this issue 3 months ago • 4 comments

Guys... look at this:

https://github.com/magento/magento2/blob/c89312182ef2e747b47348e9cd1f1148ba7af078/app/code/Magento/SalesGraphQl/etc/schema.graphqls#L216

This shouldn't be "non-nullable", because:

  • Nothing in the admin prevents from submitting a shipment with empty (null) title. It is not a required field.
  • When we query a shipment with empty (null) title through GraphQL, it results in an error:
    "errors": [
        {
            "message": "Internal server error",
            "locations": [
                {
                    "line": 1,
                    "column": 704
                }
            ],
            "path": [
                "customer",
                "orders",
                "items",
                0,
                "shipments",
                0,
                "tracking",
                0,
                "title"
            ],
            "extensions": {
                "debugMessage": "Cannot return null for non-nullable field \"ShipmentTracking.title\"."
            }
        }
    ]

In order to fix this bug locally, I had to overwrite the GraphQL schema definition for ShipmentTracking.title field, making it nullable:

type ShipmentTracking @doc(description: "Contains order shipment tracking details.") {
    title: String @doc(description: "The shipment tracking title.")
}

Please make it nullable so it works for everyone without the need to override.

Thanks!

jbruni avatar May 21 '24 12:05 jbruni