forked from saleor/saleor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "resolve_wishlist_items_from_user"
to suppress the "unused root/user argument"
- Loading branch information
Showing
2 changed files
with
14 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
from typing import TYPE_CHECKING, List | ||
|
||
from graphql_jwt.decorators import login_required | ||
|
||
from ...wishlist.models import Wishlist, WishlistItem | ||
from ...wishlist.models import Wishlist | ||
|
||
if TYPE_CHECKING: | ||
# flake8: noqa | ||
# pylint: disable=unused-import | ||
from graphene.types import ResolveInfo | ||
from ...account.models import User | ||
|
||
|
||
@login_required | ||
def resolve_wishlist_from_info(info: "ResolveInfo") -> Wishlist: | ||
def resolve_wishlist_from_user(user: "User") -> Wishlist: | ||
"""Return wishlist of the logged in user.""" | ||
user = info.context.user | ||
return Wishlist.objects.get_or_create(user) | ||
wishlist = Wishlist.objects.get_or_create(user) | ||
return wishlist | ||
|
||
|
||
@login_required | ||
def resolve_wishlist_items_from_info(info: "ResolveInfo") -> List[WishlistItem]: | ||
def resolve_wishlist_from_info(info: "ResolveInfo") -> Wishlist: | ||
"""Return wishlist of the logged in user.""" | ||
user = info.context.user | ||
wishlist = Wishlist.objects.get_or_create(user) | ||
return resolve_wishlist_from_user(user) | ||
|
||
|
||
def resolve_wishlist_items_from_user(user: "User") -> List[Wishlist]: | ||
"""Return wishlist items of the logged in user.""" | ||
wishlist = resolve_wishlist_from_user(user) | ||
return wishlist.items.all() |