Skip to content

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

Fix total count on connection resolver without first or last (#6975)

Filip Owczarekc49866aaadd8
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 86441c1194..8ce792e3eb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Deprecate API fields `Order.discount`, `Order.discountName`, `Order.translatedDiscountName` - #6874 by @korycins
- Fix argument validation in page resolver - #6960 by @fowczarek
- Drop `data` field from checkout line model - #6961 by @fowczarek
+- Fix `totalCount` on connection resolver without `first` or `last` - #6975 by @fowczarek
### Breaking
- Multichannel MVP: Multicurrency - #6242 by @fowczarek @d-wysocki
diff --git a/saleor/graphql/core/connection.py b/saleor/graphql/core/connection.py
index 9e2498138c..8dbf3a6e0f 100644
--- a/saleor/graphql/core/connection.py
+++ b/saleor/graphql/core/connection.py
@@ -159,6 +159,10 @@ def _get_edges_for_connection(edge_type, qs, args, sorting_fields):
cursor = after or before
requested_count = first or last
+ # If we don't receive `first` and `last` we shouldn't build `edges` and `page_info`
+ if not first and not last:
+ return [], {}
+
if last:
start_slice, end_slice = 1, None
else: