diff --git a/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php b/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php index a2b8280fc3d0d..ad32f953ef9c4 100644 --- a/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php +++ b/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php @@ -41,18 +41,16 @@ public function resolve( array $value = null, array $args = null ) { - $customerId = $context->getUserId(); - /* Guest checking */ - if (!$customerId && 0 === $customerId) { + if (false === $context->getExtensionAttributes()->getIsCustomer()) { throw new GraphQlAuthorizationException(__('The current user cannot perform operations on wishlist')); } - $collection = $this->_wishlistCollectionFactory->create()->filterByCustomerId($customerId); - $wishlists = $collection->getItems(); + $collection = $this->_wishlistCollectionFactory->create()->filterByCustomerId($context->getUserId()); $wishlistsData = []; - if (0 === count($wishlists)) { + if (0 === $collection->getSize()) { return $wishlistsData; } + $wishlists = $collection->getItems(); foreach ($wishlists as $wishlist) { $wishlistsData [] = [ diff --git a/app/code/Magento/WishlistGraphQl/etc/schema.graphqls b/app/code/Magento/WishlistGraphQl/etc/schema.graphqls index 28d80c4a21884..6a833efd7c2a5 100644 --- a/app/code/Magento/WishlistGraphQl/etc/schema.graphqls +++ b/app/code/Magento/WishlistGraphQl/etc/schema.graphqls @@ -10,7 +10,7 @@ type Customer { } type WishlistOutput @doc(description: "Deprecated: 'Wishlist' type should be used instead") { - items: [WishlistItem] @deprecated(reason: "Use field `items` from type `Wishlist` instead") @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\WishlistItemsResolver") @doc(description: "An array of items in the customer's wish list"), + items: [WishlistItem] @deprecated(reason: "Use field `items` from type `Wishlist` instead") @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\WishlistItemsResolver") @doc(description: "An array of items in the customer's wish list"), items_count: Int @deprecated(reason: "Use field `items_count` from type `Wishlist` instead") @doc(description: "The number of items in the wish list"), name: String @deprecated(reason: "This field is related to Commerce functionality and is always null in Open source edition") @doc(description: "When multiple wish lists are enabled, the name the customer assigns to the wishlist"), sharing_code: String @deprecated(reason: "Use field `sharing_code` from type `Wishlist` instead") @doc(description: "An encrypted code that Magento uses to link to the wish list"),