Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Return list of nodes instead of queryset
Adam Janik20d0ff49814b
diff --git a/saleor/graphql/utils.py b/saleor/graphql/utils.pyindex 532942e764..3e4a26c448 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 queryset of nodes of proper type."""+ """Return a list 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)- nodes = graphene_type._meta.model.objects.filter(pk__in=pks)+ nodes = list(graphene_type._meta.model.objects.filter(pk__in=pks))if not nodes:raise Exception("Could not resolve to a nodes with the global id list of '%s'."diff --git a/tests/api/test_graphql.py b/tests/api/test_graphql.pyindex 00f3bbd32e..ccfdff87fb 100644--- a/tests/api/test_graphql.py+++ b/tests/api/test_graphql.py@@ -241,7 +241,7 @@ def test_get_nodes(product_list):global_ids.append(to_global_id('Product', product_list[0].pk))# Return products corresponding to global idsproducts = get_nodes(global_ids, Product)- assert list(products) == product_list+ assert products == product_list# Raise an error if requested id has no related database objectnonexistent_item = Mock(type='Product', pk=123)