Skip to content

Saleor Core: the high performance, composable, headless commerce API.

remove redundant dataloader (#13161)

Jakub65a07d9986ec
diff --git a/saleor/graphql/order/types.py b/saleor/graphql/order/types.py
index 9a7429ff96..949870e711 100644
--- a/saleor/graphql/order/types.py
+++ b/saleor/graphql/order/types.py
@@ -115,10 +115,10 @@ from ..plugins.dataloaders import (
plugin_manager_promise_callback,
)
from ..product.dataloaders import (
+ ImagesByProductIdLoader,
MediaByProductVariantIdLoader,
ProductByVariantIdLoader,
ProductChannelListingByProductIdAndChannelSlugLoader,
- ProductImageByProductIdLoader,
ProductVariantByIdLoader,
ThumbnailByProductMediaIdSizeAndFormatLoader,
)
@@ -782,7 +782,7 @@ class OrderLine(ModelObjectType[models.OrderLine]):
# we failed to get image from variant, lets use first from product
return (
- ProductImageByProductIdLoader(info.context)
+ ImagesByProductIdLoader(info.context)
.load(product.id)
.then(_get_first_product_image)
)
diff --git a/saleor/graphql/product/dataloaders/__init__.py b/saleor/graphql/product/dataloaders/__init__.py
index 2c8d51942a..27c0144c15 100644
--- a/saleor/graphql/product/dataloaders/__init__.py
+++ b/saleor/graphql/product/dataloaders/__init__.py
@@ -23,7 +23,6 @@ from .products import (
ProductChannelListingByIdLoader,
ProductChannelListingByProductIdAndChannelSlugLoader,
ProductChannelListingByProductIdLoader,
- ProductImageByProductIdLoader,
ProductMediaByIdLoader,
ProductTypeByIdLoader,
ProductTypeByProductIdLoader,
@@ -60,7 +59,6 @@ __all__ = [
"ProductTypeByVariantIdLoader",
"ProductChannelListingByIdLoader",
"ProductChannelListingByProductIdLoader",
- "ProductImageByProductIdLoader",
"ProductChannelListingByProductIdAndChannelSlugLoader",
"ProductTypeByIdLoader",
"ProductVariantByIdLoader",
diff --git a/saleor/graphql/product/dataloaders/products.py b/saleor/graphql/product/dataloaders/products.py
index 3a0ae7800a..d9b5600847 100644
--- a/saleor/graphql/product/dataloaders/products.py
+++ b/saleor/graphql/product/dataloaders/products.py
@@ -422,20 +422,6 @@ class ProductImageByIdLoader(DataLoader):
return [images.get(product_image_id) for product_image_id in keys]
-class ProductImageByProductIdLoader(DataLoader):
- context_key = "product_image_by_product_id"
-
- def batch_load(self, keys):
- medias = ProductMedia.objects.using(self.database_connection_name).filter(
- type=ProductMediaTypes.IMAGE,
- product_id__in=keys,
- )
- product_id_medias_map = defaultdict(list)
- for media in medias.iterator():
- product_id_medias_map[media.product_id].append(media)
- return [product_id_medias_map.get(product_id, []) for product_id in keys]
-
-
class MediaByProductVariantIdLoader(DataLoader):
context_key = "media_by_product_variant"