Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Refactor gift card resolvers
fowczarekfc70ada1a7b2
diff --git a/saleor/graphql/giftcard/resolvers.py b/saleor/graphql/giftcard/resolvers.pyindex 11085969dc..ea905d8fdc 100644--- a/saleor/graphql/giftcard/resolvers.py+++ b/saleor/graphql/giftcard/resolvers.py@@ -1,19 +1,12 @@import graphenefrom ...giftcard import models-from ...graphql.core.utils import from_global_id_strict_type-from ..core.utils import get_node_optimizedfrom .types import GiftCarddef resolve_gift_card(info, gift_card_global_id):- """Return gift card only for user assigned to it or proper staff user."""- user = info.context.user- if user.has_perm("giftcard.manage_gift_card"):- return graphene.Node.get_node_from_global_id(- info, gift_card_global_id, GiftCard- )- gift_card_id = from_global_id_strict_type(info, gift_card_global_id, GiftCard)- return get_node_optimized(- models.GiftCard.objects, {"pk": gift_card_id, "user": user}, info- )+ return graphene.Node.get_node_from_global_id(info, gift_card_global_id, GiftCard)+++def resolve_gift_cards():+ return models.GiftCard.objects.all()diff --git a/saleor/graphql/giftcard/schema.py b/saleor/graphql/giftcard/schema.pyindex 2210b93d23..d704bcb9c2 100644--- a/saleor/graphql/giftcard/schema.py+++ b/saleor/graphql/giftcard/schema.py@@ -1,7 +1,6 @@import graphenefrom graphql_jwt.decorators import permission_required-from ...giftcard import modelsfrom ..core.fields import PrefetchingConnectionFieldfrom .mutations import (GiftCardActivate,@@ -9,7 +8,7 @@ from .mutations import (GiftCardDeactivate,GiftCardUpdate,)-from .resolvers import resolve_gift_card+from .resolvers import resolve_gift_card, resolve_gift_cardsfrom .types import GiftCard@@ -27,7 +26,7 @@ class GiftCardQueries(graphene.ObjectType):@permission_required("giftcard.manage_gift_card")def resolve_gift_cards(self, info, **_kwargs):- return models.GiftCard.objects.all()+ return resolve_gift_cards()class GiftCardMutations(graphene.ObjectType):