Skip to content

Commit

Permalink
Optimize stock warehouse resolver performance
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszszymanski129 committed Apr 20, 2022
1 parent 9aea317 commit 955489b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions saleor/graphql/warehouse/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from ..core.types import ModelObjectType, NonNullList
from ..decorators import one_of_permissions_required
from ..meta.types import ObjectWithMetadata
from .dataloaders import WarehouseByIdLoader
from .enums import WarehouseClickAndCollectOptionEnum


Expand Down Expand Up @@ -181,6 +182,12 @@ def resolve_quantity_reserved(root, info, *_args):
)
)["quantity_reserved"]

@staticmethod
def resolve_warehouse(root, info, *_args, **kwargs):
if root.warehouse_id:
return WarehouseByIdLoader(info.context).load(root.warehouse_id)
return None

@staticmethod
def resolve_product_variant(root, *_args):
return ChannelContext(node=root.product_variant, channel_slug=None)
Expand Down

0 comments on commit 955489b

Please sign in to comment.