Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Orders query address fields performance improvements (#7083)
Tomasz Szymański2829c31e0e68
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 7af11c5c5f..326abb14fe 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -36,6 +36,7 @@ All notable, unreleased changes to this project will be documented in this file.- Fix invalid tax rates for lines - #7058 by @IKarbowiak- Allow seeing unconfirmed orders - #7072 by @IKarbowiak- Raise GraphQLError when too big integer value is provided - #7076 by @IKarbowiak+- Performance upgrade on orders query with shipping and billing addresses - #7083 by @tomaszszymanski129### Breaking- Multichannel MVP: Multicurrency - #6242 by @fowczarek @d-wysockidiff --git a/saleor/graphql/order/types.py b/saleor/graphql/order/types.pyindex 667249cc44..110da7b838 100644--- a/saleor/graphql/order/types.py+++ b/saleor/graphql/order/types.py@@ -19,6 +19,7 @@ from ...order.models import FulfillmentStatusfrom ...order.utils import get_order_country, get_valid_shipping_methods_for_orderfrom ...product.product_images import get_product_image_thumbnailfrom ...warehouse import models as warehouse_models+from ..account.dataloaders import AddressByIdLoaderfrom ..account.types import Userfrom ..account.utils import requestor_has_accessfrom ..channel import ChannelContext@@ -693,15 +694,23 @@ class Order(CountableDjangoObjectType):def resolve_billing_address(root: models.Order, info):requester = get_user_or_app_from_context(info.context)if requestor_has_access(requester, root.user, OrderPermissions.MANAGE_ORDERS):- return root.billing_address- return obfuscate_address(root.billing_address)+ return AddressByIdLoader(info.context).load(root.billing_address_id)+ return (+ AddressByIdLoader(info.context)+ .load(root.billing_address_id)+ .then(obfuscate_address)+ )@staticmethoddef resolve_shipping_address(root: models.Order, info):requester = get_user_or_app_from_context(info.context)if requestor_has_access(requester, root.user, OrderPermissions.MANAGE_ORDERS):- return root.shipping_address- return obfuscate_address(root.shipping_address)+ return AddressByIdLoader(info.context).load(root.shipping_address_id)+ return (+ AddressByIdLoader(info.context)+ .load(root.shipping_address_id)+ .then(obfuscate_address)+ )@staticmethoddef resolve_shipping_price(root: models.Order, _info):