Description
This builds upon #39282
- As a developer, I want to use GraphQl in Magento and handle errors like other GraphQl applications.
- As a developer, I want placeOrder errors to trigger New Relic alarms.
Before the inclusion of errors
on PlaceOrderOutput
as a result of this commit if an error occured, the response to a failed place order would look like:
{
errors: [
{ "message": " Something went wrong, etc etc..." }
]
}
Most GraphQl clients interpret this as an error and appropriately cause error handling behaviors.
After the inclusion of 8e3a2e0#diff-ac993812eff9f7c3da3b41215860c173b0e83438a39cb16a1f3332672e2c8eab an error results in:
{
data: {
placeOrder: {
order: null,
errors: [
{ "message": " Something went wrong, etc etc..." }
]
}
},
}
If anything, at the worst, this should be:
{
data: {
placeOrder: {
order: null,
errors: [
{ "message": " Something went wrong, etc etc..." }
]
}
}
errors: [
{ "message": " Something went wrong, etc etc..." }
]
}
Error handling should match the common well-defined behaviors outlined by clients like Apollo. It should not be some bespoke poorly considered implementation.
Additionally, 8e3a2e0 inadvertently causes New Relic alarms to be silenced since failed placeOrder
attempts are now returned as "success" as https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/GraphQl/Query/ErrorHandler.php#L53 is never called.