Open
Description
Preconditions and environment
Magento 2.4.8
Steps to reproduce
- Create a salesrule with a specific coupon code available for everyone with a discount amount
- Create a quote
- Apply this coupon
- Place the order
- Get the order using GraphQL with the "applied_coupons.code" node
query getOrderByNumber($orderNumber: String!) {
customer {
orders(filter: { number: { eq: $orderNumber } }) {
items {
orderNumber: number
applied_coupons {
code
}
}
}
}
}
Expected result
{
"data": {
"customer": {
"orders": {
"items": [
{
"orderNumber": "000000003",
"applied_coupons": [
{
"code": "h20"
}
]
}
]
}
}
}
}
Actual result
{
"errors": [
{
"message": "Internal server error",
"locations": [
{
"line": 7,
"column": 11
}
],
"path": [
"customer",
"orders",
"items",
0,
"applied_coupons",
0,
"code"
],
"extensions": {
"debugMessage": "Cannot return null for non-nullable field \"AppliedCoupon.code\"."
}
}
],
"data": {
"customer": {
"orders": {
"items": [
{
"orderNumber": "000000003",
"applied_coupons": [
null
]
}
]
}
}
}
}
Additional information
Because of \Magento\SalesGraphQl\Model\Formatter\Order::format()
'applied_coupons' => $orderModel->getCouponCode() ? ['code' => $orderModel->getCouponCode()] : []
This should be encapsulate in an array
'applied_coupons' => $orderModel->getCouponCode() ? [['code' => $orderModel->getCouponCode()]] : [],
Release note
GraphQL - fix issue while getting applied_coupons.code
on order
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Ready for Development