0
  • This function runs around the resolve function for coupon api on Graphql,
  • once the core function throws exception this function will catch and update the error message.

core file [module-quote-graph-ql/Model/Resolver/ApplyCouponToCart.php]

public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
   { ... 

My around plugin code in correct namespace...

      public function aroundResolve(ApplyCouponToCart $subject, callable $proceed, $cartId, $result, $couponCode)
        {
           
            $result = false;

The Postman error im getting enter image description here

2 Answers 2

0

Refer Blow Code

public function aroundResolve(Field $subject, callable $proceed, $context, ResolveInfo $info, array $value = null, array $args = null)
    {
        //do something
    }
0

You're missing to forward those agruments in your around function:

... Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)

You can try:

public function aroundResolve(ApplyCouponToCart $subject, callable $proceed, Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
    {
       
        ...
    }

Or if you are not using/modifying the arguments, you could use variadics and argument unpacking to achieve this:

public function aroundResolve(ApplyCouponToCart $subject, callable $proceed, ...$args)
    {
       
        ...
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.