Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Adjust to latest changes from master
Marcin Gębalad7d4cb376572
diff --git a/saleor/graphql/api.py b/saleor/graphql/api.pyindex 9764868f59..8a723ebd4a 100644--- a/saleor/graphql/api.py+++ b/saleor/graphql/api.py@@ -37,7 +37,7 @@ class Query(graphene.ObjectType):def resolve_products(self, info, **kwargs):return resolve_products(info)- def resolve_attributes(self, info, in_category=None):+ def resolve_attributes(self, info, in_category=None, **kwargs):return resolve_attributes(in_category, info)diff --git a/saleor/graphql/product/types.py b/saleor/graphql/product/types.pyindex e489c49f77..15f801c2ce 100644--- a/saleor/graphql/product/types.py+++ b/saleor/graphql/product/types.py@@ -8,7 +8,7 @@ from ...product.templatetags.product_images import product_first_imagefrom ...product.utils import get_availabilityfrom ..core.filters import DistinctFilterSetfrom ..core.types import CountableDjangoObjectType, Price, PriceRange-from ..utils import CategoryAncestorsCache, get_node+from ..utils import get_nodefrom .filters import ProductFilterSet@@ -143,16 +143,6 @@ class ProductAttribute(CountableDjangoObjectType):return self.values.all()-def resolve_category(id, info):- categories = models.Category.tree.filter(id=id).get_cached_trees()- if categories:- category = categories[0]- cache = {CACHE_ANCESTORS: CategoryAncestorsCache(category)}- setattr(info.context, CONTEXT_CACHE_NAME, cache)- return category- return None--def resolve_categories(info, level=None):qs = models.Category.objects.all()if level is not None:@@ -160,11 +150,6 @@ def resolve_categories(info, level=None):return qs.distinct()-def resolve_product(id, info):- products = models.Product.objects.available_products().filter(id=id)- return products.first()--def resolve_products(info):return models.Product.objects.available_products().distinct()diff --git a/saleor/graphql/utils.py b/saleor/graphql/utils.pyindex 971e7028fb..73293b9684 100644--- a/saleor/graphql/utils.py+++ b/saleor/graphql/utils.py@@ -1,23 +1,6 @@import graphene-class CategoryAncestorsCache:- """Cache used to store ancestors of a category in GraphQL context.-- Allows to reduce the number of database queries. Categories of the same- tree depth level have common ancestors, which allows us to cache them by- the level.- """-- def __init__(self, category):- self._cache = {category.level: category.get_ancestors()}-- def get(self, category):- if category.level not in self._cache:- self._cache[category.level] = category.get_ancestors()- return self._cache[category.level]--def get_node(info, id, only_type=None):"""Return node or throw an error if the node does not exist."""node = graphene.Node.get_node_from_global_id(info, id, only_type=only_type)diff --git a/tests/test_graphql.py b/tests/test_graphql.pyindex 3909908f1f..e29e11908f 100644--- a/tests/test_graphql.py+++ b/tests/test_graphql.py@@ -419,5 +419,5 @@ def test_real_query(client, product_in_stock):'sortBy': 'name','first': 1,'attributesFilter': [filter_by]})})- content = get_content(response)+ content = get_graphql_content(response)assert 'errors' not in content