Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Model Wishlist key is added if it misssed to pass in graphql.
  • Loading branch information
Vasudev-22 committed Jul 11, 2023
commit 4a88183f733bdcfa3a9e37fdd5b57acf8cb04620
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Magento\WishlistGraphQl\Model\Resolver;

use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
Expand All @@ -17,12 +16,18 @@
use Magento\Wishlist\Model\ResourceModel\Item\CollectionFactory as WishlistItemCollectionFactory;
use Magento\Wishlist\Model\Item;
use Magento\Wishlist\Model\Wishlist;
use Magento\Wishlist\Model\WishlistFactory;

/**
* Fetches the Wishlist Items data according to the GraphQL schema
*/
class WishlistItemsResolver implements ResolverInterface
{
/**
* @var WishlistFactory
*/
private $wishlistFactory;

/**
* @var WishlistItemCollectionFactory
*/
Expand All @@ -36,13 +41,16 @@ class WishlistItemsResolver implements ResolverInterface
/**
* @param WishlistItemCollectionFactory $wishlistItemCollectionFactory
* @param StoreManagerInterface $storeManager
* @param WishlistFactory $wishlistFactory
*/
public function __construct(
WishlistItemCollectionFactory $wishlistItemCollectionFactory,
StoreManagerInterface $storeManager
StoreManagerInterface $storeManager,
WishlistFactory $wishlistFactory
) {
$this->wishlistItemCollectionFactory = $wishlistItemCollectionFactory;
$this->storeManager = $storeManager;
$this->wishlistFactory = $wishlistFactory;
}

/**
Expand All @@ -56,7 +64,7 @@ public function resolve(
array $args = null
) {
if (!isset($value['model'])) {
throw new LocalizedException(__('Missing key "model" in Wishlist value data'));
$value['model'] = $this->wishlistFactory->create();
}
/** @var Wishlist $wishlist */
$wishlist = $value['model'];
Expand Down