Open JesseMaxwell opened 1 month ago
Because Coupon is a cart fragment, it imports more than needed. It also causes the Coupon component to update anytime the cart updates.
I wouldn't expect that to happen specifically, but it does seem to happen because of: https://github.com/graphcommerce-org/graphcommerce/blob/canary/packages/magento-cart-checkout/fragments/InjectTotalsIntoCoupon.graphql
I'm not exactly sure why it is there, but then again, the totals do need to be refetched when the coupon changes, right? but it seems that CartTotals fetches a lot which isn't necessary? Coupons can affect shipping method pricing, I think?
Describe the Bug
The
CouponAccordion
uses a query:GetCouponDocument
. This imports (node_modules/@graphcommerce/magento-cart-coupon/CouponAccordion/GetCoupon.graphql
):Which imports (
node_modules/@graphcommerce/magento-cart-coupon/Api/Coupon.graphql
):Problem
Because
Coupon
is a cart fragment, it imports more than needed. It also causes the Coupon component to update anytime the cart updates.Recommendation
Add the Coupon's fragment directly to the
GetCoupon
for a leaner request and less frequent Coupon component updates.Expected Behavior
Coupon query does not get shipping addresses and cart prices.
To Reproduce