Skip to content

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

Fix multiple db queries in dataloaders (#15116)

Maciej Korycinski61b369dad37a
diff --git a/saleor/graphql/plugins/dataloaders.py b/saleor/graphql/plugins/dataloaders.py
index 029db64971..ddc6b28202 100644
--- a/saleor/graphql/plugins/dataloaders.py
+++ b/saleor/graphql/plugins/dataloaders.py
@@ -55,9 +55,8 @@ def plugin_manager_promise(context: SaleorContext, app) -> Promise[PluginsManage
def get_plugin_manager_promise(context: SaleorContext) -> Promise[PluginsManager]:
- return get_app_promise(context).then(
- partial(plugin_manager_promise, context) # type: ignore[arg-type] # mypy incorrectly assumes the return type to be a promise of a promise # noqa: E501
- )
+ app = get_app_promise(context).get()
+ return plugin_manager_promise(context, app)
def plugin_manager_promise_callback(func):
diff --git a/saleor/graphql/warehouse/tests/benchmark/test_stock_bulk_update.py b/saleor/graphql/warehouse/tests/benchmark/test_stock_bulk_update.py
index 6879f873b7..d554aeea6b 100644
--- a/saleor/graphql/warehouse/tests/benchmark/test_stock_bulk_update.py
+++ b/saleor/graphql/warehouse/tests/benchmark/test_stock_bulk_update.py
@@ -15,6 +15,12 @@ STOCKS_BULK_UPDATE_MUTATION = """
code
}
stock{
+ warehouse{
+ id
+ }
+ productVariant{
+ id
+ }
id
quantity
}
@@ -71,7 +77,7 @@ def test_stocks_bulk_update_queries_count(
]
# test number of queries when single object is updated
- with django_assert_num_queries(10):
+ with django_assert_num_queries(12):
staff_api_client.user.user_permissions.add(permission_manage_products)
response = staff_api_client.post_graphql(
STOCKS_BULK_UPDATE_MUTATION, {"stocks": stocks_input}
@@ -107,7 +113,7 @@ def test_stocks_bulk_update_queries_count(
]
# Test number of queries when multiple objects are updated
- with django_assert_num_queries(10):
+ with django_assert_num_queries(12):
staff_api_client.user.user_permissions.add(permission_manage_products)
response = staff_api_client.post_graphql(
STOCKS_BULK_UPDATE_MUTATION, {"stocks": stocks_input}