Skip to content

Commit

Permalink
GraphQL-141: [Mutations] Cart Operations > Add simple product to Cart
Browse files Browse the repository at this point in the history
-- fix static builds
  • Loading branch information
Valeriy Nayda committed Sep 26, 2018
1 parent ada51dc commit 484c65c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@

/**
* Catalog product option date validator
*
* {@inheritdoc}
*/
class DateType extends ProductDateOptionType
{
/**
* Make valid string as a value of date option type for GraphQl queries
*
* {@inheritdoc}
*
* @param array $values All product option values, i.e. array (option_id => mixed, option_id => mixed...)
* @return $this
*/
public function validateUserValue($values)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public function execute(string $cartHash, array $cartItems): Quote
}

/**
* Get cart
*
* @param string $cartHash
* @return Quote
* @throws GraphQlNoSuchEntityException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private function extractSku(array $cartItemData): string
{
$sku = $this->arrayManager->get('data/sku', $cartItemData);
if (!isset($sku)) {
throw new GraphQlInputException( __('Missing key "sku" in cart item data'));
throw new GraphQlInputException(__('Missing key "sku" in cart item data'));
}
return (string)$sku;
}
Expand All @@ -108,7 +108,7 @@ private function extractQty(array $cartItemData): float
{
$qty = $this->arrayManager->get('data/qty', $cartItemData);
if (!isset($qty)) {
throw new GraphQlInputException( __('Missing key "qty" in cart item data'));
throw new GraphQlInputException(__('Missing key "qty" in cart item data'));
}
return (float)$qty;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Magento\QuoteGraphQl\Model\Resolver;

use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Query\Resolver\TypeResolverInterface;

/**
Expand All @@ -31,6 +32,9 @@ public function __construct(array $supportedTypes = [])
/**
* {@inheritdoc}
*
* @param array $data
* @return string
* @throws GraphQlInputException
* @throws LocalizedException
*/
public function resolveType(array $data) : string
Expand Down

0 comments on commit 484c65c

Please sign in to comment.