-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
magento graphql-ce#920: Remove name from WishlistOutput
- Loading branch information
1 parent
282b09b
commit acbc881
Showing
4 changed files
with
76 additions
and
89 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistResolver.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\WishlistGraphQl\Model\Resolver; | ||
|
||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Query\ResolverInterface; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
use Magento\Wishlist\Model\WishlistFactory; | ||
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException; | ||
|
||
/** | ||
* Fetches the Wishlists data according to the GraphQL schema | ||
*/ | ||
class CustomerWishlistResolver implements ResolverInterface | ||
{ | ||
/** | ||
* @var WishlistFactory | ||
*/ | ||
private $wishlistFactory; | ||
|
||
/** | ||
* @param WishlistFactory $wishlistFactory | ||
*/ | ||
public function __construct(WishlistFactory $wishlistFactory) | ||
{ | ||
$this->wishlistFactory = $wishlistFactory; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function resolve( | ||
Field $field, | ||
$context, | ||
ResolveInfo $info, | ||
array $value = null, | ||
array $args = null | ||
) { | ||
/* Guest checking */ | ||
if (false === $context->getExtensionAttributes()->getIsCustomer()) { | ||
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.')); | ||
} | ||
$wishlist = $this->wishlistFactory->create()->loadByCustomerId($context->getUserId(), true); | ||
return [ | ||
'id' => (string) $wishlist->getId(), | ||
'sharing_code' => $wishlist->getSharingCode(), | ||
'updated_at' => $wishlist->getUpdatedAt(), | ||
'items_count' => $wishlist->getItemsCount(), | ||
'model' => $wishlist, | ||
]; | ||
} | ||
} |
65 changes: 0 additions & 65 deletions
65
app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters