Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shaoqiany
Copy link

  1. Expose fast_order_id to cart query
  2. Expose fast_order_item_uuid to cart item query
  3. Support setting fast_order_id in cart mutation
  4. Support setting fast_order_item_uuid in cart item mutation

The following are not done yet:

  1. Expose fast_order_id to order query
  2. Expose fast_order_item_uuid to order item query

Copy link
Contributor

@vsavadi vsavadi left a 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/
Copy link
Contributor

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'));
Copy link
Contributor

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 */
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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'));
Copy link
Contributor

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 */
Copy link
Contributor

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;
Copy link
Contributor

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(
Copy link
Contributor

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;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants