Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Return queryset instead of arbitrary list type
akjanik7a2c6b3e5b4d
diff --git a/saleor/graphql/utils.py b/saleor/graphql/utils.pyindex e99b8e67f6..8984681ba0 100644--- a/saleor/graphql/utils.py+++ b/saleor/graphql/utils.py@@ -16,14 +16,14 @@ def get_node(info, id, only_type=None):def get_nodes(ids, graphene_type):- """Return list of nodes of proper type."""+ """Return queryset of nodes of proper type."""pks = []for graphql_id in ids:_type, _id = from_global_id(graphql_id)assert str(graphene_type) == _type, ('Must receive an {} id.').format(graphene_type._meta.name)pks.append(_id)- return list(graphene_type._meta.model.objects.filter(pk__in=pks))+ return graphene_type._meta.model.objects.filter(pk__in=pks)def get_attributes_dict_from_list(attributes, attr_slug_id):diff --git a/tests/api/test_graphql.py b/tests/api/test_graphql.pyindex 6eefc266b6..2c18a2dabb 100644--- a/tests/api/test_graphql.py+++ b/tests/api/test_graphql.py@@ -239,7 +239,7 @@ def test_get_nodes(product_list):global_ids = [to_global_id('Product', product.pk) for product in product_list]# Return products corresponding to global idsproducts = get_nodes(global_ids, Product)- assert products == product_list+ assert list(products) == product_list# Raise an error if one of the node is of wrong typeinvalid_item = Mock(type='test', pk=123)