Skip to content

Resolved - Missing key \"model\" in Wishlist value data #37746

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 7 commits into
base: 2.4-develop
Choose a base branch
from
Open
Changes from all commits
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
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