Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Extract channel dataloaders to module (#18169)
Lukasz Ostrowski2038eee80a00
diff --git a/saleor/graphql/account/types.py b/saleor/graphql/account/types.pyindex b30031ad86..41d35fa640 100644--- a/saleor/graphql/account/types.py+++ b/saleor/graphql/account/types.py@@ -24,7 +24,7 @@ from ...thumbnail.utils import (from ..account.utils import check_is_owner_or_has_one_of_permsfrom ..app.dataloaders import AppByIdLoader, get_app_promisefrom ..app.types import App-from ..channel.dataloaders import ChannelBySlugLoader+from ..channel.dataloaders.by_self import ChannelBySlugLoaderfrom ..channel.types import Channelfrom ..checkout.dataloaders import CheckoutByUserAndChannelLoader, CheckoutByUserLoaderfrom ..checkout.types import Checkout, CheckoutCountableConnectiondiff --git a/saleor/graphql/channel/dataloaders/__init__.py b/saleor/graphql/channel/dataloaders/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/saleor/graphql/channel/dataloaders/by_checkout.py b/saleor/graphql/channel/dataloaders/by_checkout.pynew file mode 100644index 0000000000..1e00707cdf--- /dev/null+++ b/saleor/graphql/channel/dataloaders/by_checkout.py@@ -0,0 +1,28 @@+from uuid import UUID++from ....channel.models import Channel+from ...checkout.dataloaders import CheckoutByTokenLoader+from ...core.dataloaders import DataLoader+from .by_self import ChannelByIdLoader+++class ChannelByCheckoutIDLoader(DataLoader[UUID, Channel]):+ context_key = "channel_by_checkout"++ def batch_load(self, keys):+ def with_checkouts(checkouts):+ def with_channels(channels):+ channel_map = {channel.id: channel for channel in channels}+ return [+ channel_map.get(checkout.channel_id) if checkout else None+ for checkout in checkouts+ ]++ channel_ids = {checkout.channel_id for checkout in checkouts if checkout}+ return (+ ChannelByIdLoader(self.context)+ .load_many(channel_ids)+ .then(with_channels)+ )++ return CheckoutByTokenLoader(self.context).load_many(keys).then(with_checkouts)diff --git a/saleor/graphql/channel/dataloaders.py b/saleor/graphql/channel/dataloaders/by_order.pysimilarity index 64%rename from saleor/graphql/channel/dataloaders.pyrename to saleor/graphql/channel/dataloaders/by_order.pyindex 1a2017f48d..26d443da2d 100644--- a/saleor/graphql/channel/dataloaders.py+++ b/saleor/graphql/channel/dataloaders/by_order.py@@ -2,28 +2,11 @@ from uuid import UUIDfrom django.db.models import Exists, OuterRef-from ...channel.models import Channel-from ...order.models import Order-from ..core.dataloaders import DataLoader-from ..order.dataloaders import OrderByIdLoader---class ChannelByIdLoader(DataLoader[int, Channel]):- context_key = "channel_by_id"-- def batch_load(self, keys):- channels = Channel.objects.using(self.database_connection_name).in_bulk(keys)- return [channels.get(channel_id) for channel_id in keys]---class ChannelBySlugLoader(DataLoader[str, Channel]):- context_key = "channel_by_slug"-- def batch_load(self, keys):- channels = Channel.objects.using(self.database_connection_name).in_bulk(- keys, field_name="slug"- )- return [channels.get(slug) for slug in keys]+from ....channel.models import Channel+from ....order.models import Order+from ...core.dataloaders import DataLoader+from ...order.dataloaders import OrderByIdLoader+from .by_self import ChannelByIdLoaderclass ChannelByOrderIdLoader(DataLoader[UUID, Channel]):diff --git a/saleor/graphql/channel/dataloaders/by_self.py b/saleor/graphql/channel/dataloaders/by_self.pynew file mode 100644index 0000000000..06ac56f4cf--- /dev/null+++ b/saleor/graphql/channel/dataloaders/by_self.py@@ -0,0 +1,20 @@+from ....channel.models import Channel+from ...core.dataloaders import DataLoader+++class ChannelByIdLoader(DataLoader[int, Channel]):+ context_key = "channel_by_id"++ def batch_load(self, keys):+ channels = Channel.objects.using(self.database_connection_name).in_bulk(keys)+ return [channels.get(channel_id) for channel_id in keys]+++class ChannelBySlugLoader(DataLoader[str, Channel]):+ context_key = "channel_by_slug"++ def batch_load(self, keys):+ channels = Channel.objects.using(self.database_connection_name).in_bulk(+ keys, field_name="slug"+ )+ return [channels.get(slug) for slug in keys]diff --git a/saleor/graphql/channel/dataloaders/by_transaction.py b/saleor/graphql/channel/dataloaders/by_transaction.pynew file mode 100644index 0000000000..fe6be9f34a--- /dev/null+++ b/saleor/graphql/channel/dataloaders/by_transaction.py@@ -0,0 +1,70 @@+from collections.abc import Iterable++from promise import Promise++from ....channel.models import Channel+from ....payment.models import TransactionItem+from ...core.dataloaders import DataLoader+from .by_checkout import ChannelByCheckoutIDLoader+from .by_order import ChannelByOrderIdLoader+++class ChannelByTransactionIdLoader(DataLoader[int, Channel]):+ context_key = "channel_by_transaction_id"++ def batch_load(self, keys: Iterable[int]):+ transaction_ids = list(keys)++ transaction_items = (+ TransactionItem.objects.using(self.database_connection_name)+ .only("order_id", "checkout_id", "id")+ .in_bulk(transaction_ids)+ )++ transaction_to_order = {+ item.id: item.order_id+ for item in transaction_items.values()+ if item.order_id+ }++ transaction_to_checkout = {+ item.id: item.checkout_id+ for item in transaction_items.values()+ if item.checkout_id+ }++ order_ids = [+ order_id+ for transaction_id in transaction_ids+ if (order_id := transaction_to_order.get(transaction_id)) is not None+ ]++ checkout_ids = [+ checkout_id+ for transaction_id in transaction_ids+ if (checkout_id := transaction_to_checkout.get(transaction_id)) is not None+ ]++ def resolve_channels(loaded_data):+ checkout_channels, order_channels = loaded_data++ order_to_channel = dict(zip(order_ids, order_channels, strict=False))+ checkout_to_channel = dict(+ zip(checkout_ids, checkout_channels, strict=False)+ )++ def get_channel_for_transaction(transaction_id):+ if order_id := transaction_to_order.get(transaction_id):+ return order_to_channel.get(order_id)+ if checkout_id := transaction_to_checkout.get(transaction_id):+ return checkout_to_channel.get(checkout_id)+ return None++ return [get_channel_for_transaction(tid) for tid in transaction_ids]++ checkout_promise = ChannelByCheckoutIDLoader(self.context).load_many(+ checkout_ids+ )+ order_promise = ChannelByOrderIdLoader(self.context).load_many(order_ids)++ return Promise.all([checkout_promise, order_promise]).then(resolve_channels)diff --git a/saleor/graphql/channel/tests/dataloaders/__init__.py b/saleor/graphql/channel/tests/dataloaders/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/saleor/graphql/channel/tests/dataloaders/test_by_transaction.py b/saleor/graphql/channel/tests/dataloaders/test_by_transaction.pynew file mode 100644index 0000000000..9f051898a3--- /dev/null+++ b/saleor/graphql/channel/tests/dataloaders/test_by_transaction.py@@ -0,0 +1,179 @@+from .....channel.models import Channel+from ....context import SaleorContext+from ...dataloaders.by_transaction import ChannelByTransactionIdLoader+++def test_batch_load_with_order_transactions(+ order_with_lines, transaction_item_generator+):+ # given+ order = order_with_lines+ transaction1 = transaction_item_generator(order_id=order.id, checkout_id=None)+ transaction2 = transaction_item_generator(order_id=order.id, checkout_id=None)++ # when+ context = SaleorContext()+ loader = ChannelByTransactionIdLoader(context)+ channels = loader.batch_load([transaction1.id, transaction2.id]).get()++ # then+ assert len(channels) == 2+ assert channels[0] == order.channel+ assert channels[1] == order.channel+ assert all(isinstance(channel, Channel) for channel in channels)+++def test_batch_load_with_checkout_transactions(checkout, transaction_item_generator):+ # given+ transaction1 = transaction_item_generator(checkout_id=checkout.token, order_id=None)+ transaction2 = transaction_item_generator(checkout_id=checkout.token, order_id=None)++ # when+ context = SaleorContext()+ loader = ChannelByTransactionIdLoader(context)+ channels = loader.batch_load([transaction1.id, transaction2.id]).get()++ # then+ assert len(channels) == 2+ assert channels[0] == checkout.channel+ assert channels[1] == checkout.channel+ assert all(isinstance(channel, Channel) for channel in channels)+++def test_batch_load_with_mixed_transactions(+ order_with_lines, checkout, transaction_item_generator+):+ # given+ order = order_with_lines+ order_transaction = transaction_item_generator(order_id=order.id, checkout_id=None)+ checkout_transaction = transaction_item_generator(+ checkout_id=checkout.token, order_id=None+ )++ # when+ context = SaleorContext()+ loader = ChannelByTransactionIdLoader(context)+ channels = loader.batch_load([order_transaction.id, checkout_transaction.id]).get()++ # then+ assert len(channels) == 2+ assert channels[0] == order.channel+ assert channels[1] == checkout.channel+++def test_batch_load_with_nonexistent_transaction_ids():+ # given+ nonexistent_ids = [99999, 88888]++ # when+ context = SaleorContext()+ loader = ChannelByTransactionIdLoader(context)+ channels = loader.batch_load(nonexistent_ids).get()++ # then+ assert len(channels) == 2+ assert channels[0] is None+ assert channels[1] is None+++def test_batch_load_with_transaction_without_order_or_checkout(+ transaction_item_generator,+):+ # given - transaction with neither order_id nor checkout_id+ transaction = transaction_item_generator(order_id=None, checkout_id=None)++ # when+ context = SaleorContext()+ loader = ChannelByTransactionIdLoader(context)+ channels = loader.batch_load([transaction.id]).get()++ # then+ assert len(channels) == 1+ assert channels[0] is None+++def test_batch_load_empty_keys():+ # when+ context = SaleorContext()+ loader = ChannelByTransactionIdLoader(context)+ channels = loader.batch_load([]).get()++ # then+ assert channels == []+++def test_batch_load_with_deleted_order(order_with_lines, transaction_item_generator):+ # given+ order = order_with_lines+ transaction = transaction_item_generator(order_id=order.id, checkout_id=None)+ transaction_id = transaction.id+ # Delete transaction first, then order to avoid protected foreign key constraint+ transaction.delete()+ order.delete()++ # when+ context = SaleorContext()+ loader = ChannelByTransactionIdLoader(context)+ channels = loader.batch_load([transaction_id]).get()++ # then+ assert len(channels) == 1+ assert channels[0] is None+++def test_batch_load_with_deleted_checkout(checkout, transaction_item_generator):+ # given+ transaction = transaction_item_generator(checkout_id=checkout.token, order_id=None)+ checkout.delete()++ # when+ context = SaleorContext()+ loader = ChannelByTransactionIdLoader(context)+ channels = loader.batch_load([transaction.id]).get()++ # then+ assert len(channels) == 1+ assert channels[0] is None+++def test_batch_load_maintains_order(+ order_with_lines, checkout, transaction_item_generator+):+ # given+ order = order_with_lines+ transaction1 = transaction_item_generator(order_id=order.id, checkout_id=None)+ transaction2 = transaction_item_generator(checkout_id=checkout.token, order_id=None)+ transaction3 = transaction_item_generator(order_id=order.id, checkout_id=None)++ # when+ context = SaleorContext()+ loader = ChannelByTransactionIdLoader(context)+ # Request in specific order+ channels = loader.batch_load(+ [transaction2.id, transaction1.id, transaction3.id]+ ).get()++ # then+ assert len(channels) == 3+ # Results should match the order of request+ assert channels[0] == checkout.channel # transaction2 -> checkout+ assert channels[1] == order.channel # transaction1 -> order+ assert channels[2] == order.channel # transaction3 -> order+++def test_batch_load_handles_duplicate_transaction_ids(+ order_with_lines, transaction_item_generator+):+ # given+ order = order_with_lines+ transaction = transaction_item_generator(order_id=order.id, checkout_id=None)++ # when+ context = SaleorContext()+ loader = ChannelByTransactionIdLoader(context)+ # Request same transaction ID multiple times+ channels = loader.batch_load([transaction.id, transaction.id, transaction.id]).get()++ # then+ assert len(channels) == 3+ assert all(channel == order.channel for channel in channels)diff --git a/saleor/graphql/channel/types.py b/saleor/graphql/channel/types.pyindex 5af1bb3bf4..f81736b0d7 100644--- a/saleor/graphql/channel/types.py+++ b/saleor/graphql/channel/types.py@@ -38,7 +38,7 @@ from ..meta.types import ObjectWithMetadatafrom ..tax.dataloaders import TaxConfigurationByChannelIdfrom ..warehouse.dataloaders import WarehousesByChannelIdLoaderfrom ..warehouse.types import Warehouse-from .dataloaders import ChannelWithHasOrdersByIdLoader+from .dataloaders.by_order import ChannelWithHasOrdersByIdLoaderfrom .enums import (AllocationStrategyEnum,MarkAsPaidStrategyEnum,diff --git a/saleor/graphql/checkout/dataloaders/__init__.py b/saleor/graphql/checkout/dataloaders/__init__.pyindex 822da82f67..b3bbb8c420 100644--- a/saleor/graphql/checkout/dataloaders/__init__.py+++ b/saleor/graphql/checkout/dataloaders/__init__.py@@ -3,7 +3,6 @@ from .checkout_infos import (CheckoutLinesInfoByCheckoutTokenLoader,)from .models import (- ChannelByCheckoutIDLoader,CheckoutByTokenLoader,CheckoutByUserAndChannelLoader,CheckoutByUserLoader,@@ -19,7 +18,6 @@ from .problems import (from .promotion_rule_infos import VariantPromotionRuleInfoByCheckoutLineIdLoader__all__ = [- "ChannelByCheckoutIDLoader","CheckoutByTokenLoader","CheckoutByUserAndChannelLoader","CheckoutByUserLoader",diff --git a/saleor/graphql/checkout/dataloaders/checkout_infos.py b/saleor/graphql/checkout/dataloaders/checkout_infos.pyindex 51fc6376b3..98b36f5c5e 100644--- a/saleor/graphql/checkout/dataloaders/checkout_infos.py+++ b/saleor/graphql/checkout/dataloaders/checkout_infos.py@@ -8,7 +8,7 @@ from ....core.db.connection import allow_writer_in_contextfrom ....discount import VoucherTypefrom ....discount.utils.voucher import attach_voucher_to_line_infofrom ...account.dataloaders import AddressByIdLoader, UserByUserIdLoader-from ...channel.dataloaders import ChannelByIdLoader+from ...channel.dataloaders.by_self import ChannelByIdLoaderfrom ...core.dataloaders import DataLoaderfrom ...discount.dataloaders import (CheckoutDiscountByCheckoutIdLoader,diff --git a/saleor/graphql/checkout/dataloaders/models.py b/saleor/graphql/checkout/dataloaders/models.pyindex 61bd0de354..2af1f5083a 100644--- a/saleor/graphql/checkout/dataloaders/models.py+++ b/saleor/graphql/checkout/dataloaders/models.py@@ -1,13 +1,10 @@from collections import defaultdictfrom collections.abc import Iterable-from uuid import UUIDfrom django.db.models import F-from ....channel.models import Channelfrom ....checkout.models import Checkout, CheckoutLine, CheckoutMetadatafrom ....payment.models import TransactionItem-from ...channel.dataloaders import ChannelByIdLoaderfrom ...core.dataloaders import DataLoader@@ -78,28 +75,6 @@ class CheckoutLinesByCheckoutTokenLoader(DataLoader[str, list[CheckoutLine]]):return [line_map.get(checkout_id, []) for checkout_id in keys]-class ChannelByCheckoutIDLoader(DataLoader[UUID, Channel]):- context_key = "channel_by_checkout"-- def batch_load(self, keys):- def with_checkouts(checkouts):- def with_channels(channels):- channel_map = {channel.id: channel for channel in channels}- return [- channel_map.get(checkout.channel_id) if checkout else None- for checkout in checkouts- ]-- channel_ids = {checkout.channel_id for checkout in checkouts if checkout}- return (- ChannelByIdLoader(self.context)- .load_many(channel_ids)- .then(with_channels)- )-- return CheckoutByTokenLoader(self.context).load_many(keys).then(with_checkouts)--class CheckoutMetadataByCheckoutIdLoader(DataLoader[str, CheckoutMetadata]):context_key = "checkout_metadata_by_checkout_id"diff --git a/saleor/graphql/checkout/resolvers.py b/saleor/graphql/checkout/resolvers.pyindex c6daa56fc8..2befc2d49f 100644--- a/saleor/graphql/checkout/resolvers.py+++ b/saleor/graphql/checkout/resolvers.py@@ -7,7 +7,7 @@ from ...permission.enums import (CheckoutPermissions,PaymentPermissions,)-from ..channel.dataloaders import ChannelByIdLoader+from ..channel.dataloaders.by_self import ChannelByIdLoaderfrom ..core.context import SyncWebhookControlContext, get_database_connection_namefrom ..core.tracing import traced_resolverfrom ..core.utils import from_global_id_or_errordiff --git a/saleor/graphql/checkout/types.py b/saleor/graphql/checkout/types.pyindex 30dce70b4f..2ddc5620bf 100644--- a/saleor/graphql/checkout/types.py+++ b/saleor/graphql/checkout/types.py@@ -30,10 +30,10 @@ from ...warehouse.reservations import is_reservation_enabledfrom ...webhook.event_types import WebhookEventSyncTypefrom ..account.dataloaders import AddressByIdLoader, UserByUserIdLoaderfrom ..account.utils import check_is_owner_or_has_one_of_perms-from ..channel.dataloaders import ChannelByIdLoader+from ..channel.dataloaders.by_checkout import ChannelByCheckoutIDLoader+from ..channel.dataloaders.by_self import ChannelByIdLoaderfrom ..channel.types import Channelfrom ..checkout.dataloaders import (- ChannelByCheckoutIDLoader,CheckoutLinesProblemsByCheckoutIdLoader,CheckoutProblemsByCheckoutIdDataloader,)diff --git a/saleor/graphql/core/types/taxes.py b/saleor/graphql/core/types/taxes.pyindex d150b5b968..4964c2afa3 100644--- a/saleor/graphql/core/types/taxes.py+++ b/saleor/graphql/core/types/taxes.py@@ -17,7 +17,7 @@ from ....order.models import Order, OrderLinefrom ....order.utils import get_order_countryfrom ....tax.utils import get_charge_taxesfrom ...account.dataloaders import AddressByIdLoader-from ...channel.dataloaders import ChannelByIdLoader+from ...channel.dataloaders.by_self import ChannelByIdLoaderfrom ...channel.types import Channelfrom ...checkout import types as checkout_typesfrom ...checkout.dataloaders import (diff --git a/saleor/graphql/discount/dataloaders.py b/saleor/graphql/discount/dataloaders.pyindex 2bb3dc1e22..91a1d8d612 100644--- a/saleor/graphql/discount/dataloaders.py+++ b/saleor/graphql/discount/dataloaders.py@@ -21,7 +21,7 @@ from ...discount.models import (VoucherCode,)from ...product.models import ProductVariant-from ..channel.dataloaders import ChannelBySlugLoader+from ..channel.dataloaders.by_self import ChannelBySlugLoaderfrom ..core.dataloaders import DataLoaderif TYPE_CHECKING:diff --git a/saleor/graphql/discount/types/sales.py b/saleor/graphql/discount/types/sales.pyindex 554ae44c4c..372c5c7733 100644--- a/saleor/graphql/discount/types/sales.py+++ b/saleor/graphql/discount/types/sales.py@@ -4,7 +4,7 @@ from graphene import relayfrom ....discount import DiscountValueType, modelsfrom ....permission.enums import DiscountPermissionsfrom ....product.models import Category, Collection, Product, ProductVariant-from ...channel.dataloaders import ChannelBySlugLoader+from ...channel.dataloaders.by_self import ChannelBySlugLoaderfrom ...channel.types import Channelfrom ...core import ResolveInfofrom ...core.connection import CountableConnection, create_connection_slicediff --git a/saleor/graphql/discount/types/vouchers.py b/saleor/graphql/discount/types/vouchers.pyindex 488fb63537..c6550f05ee 100644--- a/saleor/graphql/discount/types/vouchers.py+++ b/saleor/graphql/discount/types/vouchers.py@@ -3,7 +3,7 @@ from graphene import relayfrom ....discount import modelsfrom ....permission.enums import DiscountPermissions-from ...channel.dataloaders import ChannelByIdLoader+from ...channel.dataloaders.by_self import ChannelByIdLoaderfrom ...channel.types import Channelfrom ...core import ResolveInfo, typesfrom ...core.connection import CountableConnection, create_connection_slicediff --git a/saleor/graphql/giftcard/types.py b/saleor/graphql/giftcard/types.pyindex 8368be216b..c983d41574 100644--- a/saleor/graphql/giftcard/types.py+++ b/saleor/graphql/giftcard/types.py@@ -16,7 +16,7 @@ from ..account.utils import ()from ..app.dataloaders import AppByIdLoaderfrom ..app.types import App-from ..channel.dataloaders import ChannelByIdLoader+from ..channel.dataloaders.by_self import ChannelByIdLoaderfrom ..core.connection import CountableConnectionfrom ..core.context import ChannelContext, get_database_connection_namefrom ..core.descriptions import DEFAULT_DEPRECATION_REASONdiff --git a/saleor/graphql/menu/types.py b/saleor/graphql/menu/types.pyindex ce076a3803..dabaaffd08 100644--- a/saleor/graphql/menu/types.py+++ b/saleor/graphql/menu/types.py@@ -5,7 +5,7 @@ from ...menu import modelsfrom ...permission.enums import PagePermissionsfrom ...permission.utils import has_one_of_permissionsfrom ...product.models import ALL_PRODUCTS_PERMISSIONS-from ..channel.dataloaders import ChannelBySlugLoader+from ..channel.dataloaders.by_self import ChannelBySlugLoaderfrom ..core import ResolveInfofrom ..core.connection import CountableConnectionfrom ..core.context import ChannelContextdiff --git a/saleor/graphql/order/types.py b/saleor/graphql/order/types.pyindex 5ed83938f7..09d1f911cb 100644--- a/saleor/graphql/order/types.py+++ b/saleor/graphql/order/types.py@@ -64,7 +64,8 @@ from ..account.utils import ()from ..app.dataloaders import AppByIdLoaderfrom ..app.types import App-from ..channel.dataloaders import ChannelByIdLoader, ChannelByOrderIdLoader+from ..channel.dataloaders.by_order import ChannelByOrderIdLoader+from ..channel.dataloaders.by_self import ChannelByIdLoaderfrom ..channel.types import Channelfrom ..checkout.utils import prevent_sync_event_circular_queryfrom ..core.connection import CountableConnectiondiff --git a/saleor/graphql/page/schema.py b/saleor/graphql/page/schema.pyindex 63a53dd5ff..534064e970 100644--- a/saleor/graphql/page/schema.py+++ b/saleor/graphql/page/schema.py@@ -1,6 +1,6 @@import graphene-from ..channel.dataloaders import ChannelBySlugLoader+from ..channel.dataloaders.by_self import ChannelBySlugLoaderfrom ..core import ResolveInfofrom ..core.connection import create_connection_slice, filter_connection_querysetfrom ..core.context import ChannelContextdiff --git a/saleor/graphql/product/dataloaders/products.py b/saleor/graphql/product/dataloaders/products.pyindex f69b4e69cb..24e0046a0b 100644--- a/saleor/graphql/product/dataloaders/products.py+++ b/saleor/graphql/product/dataloaders/products.py@@ -19,7 +19,7 @@ from ....product.models import (VariantChannelListingPromotionRule,VariantMedia,)-from ...channel.dataloaders import ChannelBySlugLoader+from ...channel.dataloaders.by_self import ChannelBySlugLoaderfrom ...core.dataloaders import BaseThumbnailBySizeAndFormatLoader, DataLoaderProductIdAndChannelSlug = tuple[int, str]diff --git a/saleor/graphql/product/schema.py b/saleor/graphql/product/schema.pyindex 41323b9445..a4f24a4b41 100644--- a/saleor/graphql/product/schema.py+++ b/saleor/graphql/product/schema.py@@ -7,7 +7,7 @@ from ...permission.utils import has_one_of_permissionsfrom ...product import modelsfrom ...product.models import ALL_PRODUCTS_PERMISSIONSfrom ...product.search import search_products-from ..channel.dataloaders import ChannelBySlugLoader+from ..channel.dataloaders.by_self import ChannelBySlugLoaderfrom ..channel.utils import get_default_channel_slug_or_graphql_errorfrom ..core import ResolveInfofrom ..core.connection import create_connection_slice, filter_connection_querysetdiff --git a/saleor/graphql/product/types/categories.py b/saleor/graphql/product/types/categories.pyindex 2c6b105453..cc1f43a5c0 100644--- a/saleor/graphql/product/types/categories.py+++ b/saleor/graphql/product/types/categories.py@@ -11,7 +11,7 @@ from ....thumbnail.utils import (get_thumbnail_format,get_thumbnail_size,)-from ...channel.dataloaders import ChannelBySlugLoader+from ...channel.dataloaders.by_self import ChannelBySlugLoaderfrom ...channel.utils import get_default_channel_slug_or_graphql_errorfrom ...core.connection import (CountableConnection,diff --git a/saleor/graphql/product/types/channels.py b/saleor/graphql/product/types/channels.pyindex 668a5c67e4..4e622c38e1 100644--- a/saleor/graphql/product/types/channels.py+++ b/saleor/graphql/product/types/channels.py@@ -19,7 +19,7 @@ from ....tax.utils import (get_tax_rate_for_country,)from ...account import types as account_types-from ...channel.dataloaders import ChannelByIdLoader+from ...channel.dataloaders.by_self import ChannelByIdLoaderfrom ...channel.types import Channelfrom ...core.descriptions import ADDED_IN_321from ...core.doc_category import DOC_CATEGORY_PRODUCTSdiff --git a/saleor/graphql/product/types/collections.py b/saleor/graphql/product/types/collections.pyindex 824962fe76..0e30ca2a04 100644--- a/saleor/graphql/product/types/collections.py+++ b/saleor/graphql/product/types/collections.py@@ -12,7 +12,7 @@ from ....thumbnail.utils import (get_thumbnail_format,get_thumbnail_size,)-from ...channel.dataloaders import ChannelBySlugLoader+from ...channel.dataloaders.by_self import ChannelBySlugLoaderfrom ...core import ResolveInfofrom ...core.connection import (CountableConnection,diff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.pyindex 4fab5e9ba7..ab4cc1d1ca 100644--- a/saleor/graphql/product/types/products.py+++ b/saleor/graphql/product/types/products.py@@ -53,7 +53,7 @@ from ...attribute.types import (SelectedAttribute,)from ...attribute.utils.shared import AssignedAttributeData-from ...channel.dataloaders import ChannelBySlugLoader+from ...channel.dataloaders.by_self import ChannelBySlugLoaderfrom ...channel.utils import get_default_channel_slug_or_graphql_errorfrom ...core.connection import (CountableConnection,diff --git a/saleor/graphql/shipping/dataloaders.py b/saleor/graphql/shipping/dataloaders.pyindex f029e59da0..9e68b32537 100644--- a/saleor/graphql/shipping/dataloaders.py+++ b/saleor/graphql/shipping/dataloaders.py@@ -9,6 +9,7 @@ from ...shipping.models import (ShippingMethodPostalCodeRule,ShippingZone,)+from ..channel.dataloaders.by_self import ChannelByIdLoaderfrom ..core.dataloaders import DataLoader@@ -196,8 +197,6 @@ class ChannelsByShippingZoneIdLoader(DataLoader):context_key = "channels_by_shippingzone"def batch_load(self, keys):- from ..channel.dataloaders import ChannelByIdLoader-channel_and_zone_is_pairs = (Channel.objects.using(self.database_connection_name).filter(shipping_zones__id__in=keys)diff --git a/saleor/graphql/shipping/types.py b/saleor/graphql/shipping/types.pyindex 5544a2fa17..6de34c6d42 100644--- a/saleor/graphql/shipping/types.py+++ b/saleor/graphql/shipping/types.py@@ -9,7 +9,7 @@ from ...product import models as product_modelsfrom ...shipping import modelsfrom ...shipping.interface import ShippingMethodDatafrom ..account.enums import CountryCodeEnum-from ..channel.dataloaders import ChannelByIdLoader+from ..channel.dataloaders.by_self import ChannelByIdLoaderfrom ..channel.types import Channelfrom ..core.connection import CountableConnection, create_connection_slicefrom ..core.context import (diff --git a/saleor/graphql/tax/types.py b/saleor/graphql/tax/types.pyindex a8ef538557..2f94f7da2f 100644--- a/saleor/graphql/tax/types.py+++ b/saleor/graphql/tax/types.py@@ -1,7 +1,7 @@import graphenefrom ...tax import models-from ..channel.dataloaders import ChannelByIdLoader+from ..channel.dataloaders.by_self import ChannelByIdLoaderfrom ..channel.types import Channelfrom ..core import ResolveInfofrom ..core.connection import CountableConnectiondiff --git a/saleor/graphql/warehouse/dataloaders.py b/saleor/graphql/warehouse/dataloaders.pyindex 085333d98f..9160ea0713 100644--- a/saleor/graphql/warehouse/dataloaders.py+++ b/saleor/graphql/warehouse/dataloaders.py@@ -24,7 +24,7 @@ from ...warehouse.models import (Warehouse,)from ...warehouse.reservations import is_reservation_enabled-from ..channel.dataloaders import ChannelBySlugLoader+from ..channel.dataloaders.by_self import ChannelBySlugLoaderfrom ..core.dataloaders import DataLoaderfrom ..shipping.dataloaders import (ShippingZonesByChannelIdLoader,diff --git a/saleor/graphql/webhook/subscription_types.py b/saleor/graphql/webhook/subscription_types.pyindex cb967306d9..9a4d74ebc3 100644--- a/saleor/graphql/webhook/subscription_types.py+++ b/saleor/graphql/webhook/subscription_types.py@@ -38,7 +38,7 @@ from ...webhook.const import MAX_FILTERABLE_CHANNEL_SLUGS_LIMITfrom ...webhook.event_types import WebhookEventAsyncType, WebhookEventSyncTypefrom ..account.types import User as UserTypefrom ..app.types import App as AppType-from ..channel.dataloaders import ChannelByIdLoader+from ..channel.dataloaders.by_self import ChannelByIdLoaderfrom ..channel.enums import TransactionFlowStrategyEnumfrom ..core import ResolveInfofrom ..core.context import (