-
Notifications
You must be signed in to change notification settings - Fork 0
Expose Fast_Order_Id/Fast_Order_Item_Uuid to Cart/CartItem GraphQl #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shaoqiany Just some minor changes to keep it consistent with whole module. Can you please take a look.
* | ||
* @package Fast_Checkout | ||
* @author Fast <[email protected]> | ||
* @copyright 2021 Copyright Fast AF, Inc., https://www.fast.co/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2022
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) | ||
{ | ||
if (!isset($value['model'])) { | ||
throw new LocalizedException(__('"model" value should be specified')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undefined class. Lets add use Magento\Framework\Exception\LocalizedException;
under namespaces
if (!isset($value['model'])) { | ||
throw new LocalizedException(__('"model" value should be specified')); | ||
} | ||
/** @var Quote $cart */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undefined class. Lets add use Magento\Quote\Model\Quote;
under namespace
use Magento\Framework\GraphQl\Exception\GraphQlInputException; | ||
use Magento\Framework\GraphQl\Query\ResolverInterface; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
use Magento\QuoteGraphQl\Model\Cart\GetCartForUser; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import never used
namespace Fast\Checkout\Model\Resolver\Cart; | ||
|
||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Exception\GraphQlInputException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import never used
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) | ||
{ | ||
if (!isset($value['model'])) { | ||
throw new LocalizedException(__('"model" value should be specified')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see above
if (!isset($value['model'])) { | ||
throw new LocalizedException(__('"model" value should be specified')); | ||
} | ||
/** @var Item $cartItem */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add use Magento\Quote\Model\Quote\Item;
under namespace
namespace Fast\Checkout\Model\Resolver\CartItem; | ||
|
||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Exception\GraphQlInputException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see above
$this->httpContext = $httpContext; | ||
} | ||
|
||
public function aroundResolve( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend using beforeResolve method here
/**
* @param Interceptor $subject
* @param Field $field
* @param $context
* @param ResolveInfo $info
* @param array|null $value
* @param array|null $args
* @return null
*/
public function beforeResolve(Interceptor $subject, Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
{
if (isset($args['input']['fast_order_id'])) {
// pass along the fast_order_id, so Plugin/Api/CartManagement can pick it up
$this->httpContext->setValue(self::CONTEXT_FAST_ORDER_ID_KEY, $args['input']['fast_order_id'], null);
}
//since we're not changing any parameters
return null;
}
The following are not done yet: