Skip to content

bug: placeOrder error handling is incompatible with GraphQl norms #39300

Open
@damienwebdev

Description

@damienwebdev

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: FrameworkComponent: GraphQLGraphQLIssue: 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: ready for devProject: GraphQLReported on 2.4.xIndicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions