Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Revert ancestors field
Marcin Gębalae324e53ec75d
diff --git a/saleor/graphql/product/types.py b/saleor/graphql/product/types.pyindex a5fc1aaf18..36229b0850 100644--- a/saleor/graphql/product/types.py+++ b/saleor/graphql/product/types.py@@ -432,6 +432,9 @@ class Collection(CountableDjangoObjectType):class Category(CountableDjangoObjectType):+ ancestors = PrefetchingConnectionField(+ lambda: Category,+ description='List of ancestors of the category.')products = gql_optimizer.field(PrefetchingConnectionField(Product, description='List of products in the category.'),@@ -453,6 +456,10 @@ class Category(CountableDjangoObjectType):interfaces = [relay.Node]model = models.Category+ def resolve_ancestors(self, info, **kwargs):+ qs = self.get_ancestors()+ return gql_optimizer.query(qs, info)+def resolve_background_image(self, info, **kwargs):return self.background_image or Nonediff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 574c1bc076..e428f9a1f7 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -230,6 +230,7 @@ type Category implements Node {level: Int!children(before: String, after: String, first: Int, last: Int): CategoryCountableConnectionproducts(before: String, after: String, first: Int, last: Int): ProductCountableConnection+ ancestors(before: String, after: String, first: Int, last: Int): CategoryCountableConnectionurl: String}diff --git a/tests/api/test_category.py b/tests/api/test_category.pyindex 861c00f124..45c6797557 100644--- a/tests/api/test_category.py+++ b/tests/api/test_category.py@@ -16,6 +16,13 @@ def test_category_query(user_api_client, product):category(id: "%(category_pk)s") {idname+ ancestors(last: 20) {+ edges {+ node {+ name+ }+ }+ }children(first: 20) {edges {node {@@ -31,6 +38,9 @@ def test_category_query(user_api_client, product):category_data = content['data']['category']assert category_data is not Noneassert category_data['name'] == category.name+ assert (+ len(category_data['ancestors']['edges']) ==+ category.get_ancestors().count())assert (len(category_data['children']['edges']) ==category.get_children().count())diff --git a/tests/api/test_graphql.py b/tests/api/test_graphql.pyindex 2662143e36..705a73178a 100644--- a/tests/api/test_graphql.py+++ b/tests/api/test_graphql.py@@ -68,6 +68,16 @@ def test_real_query(user_api_client, product):idnameurl+ ancestors(last: 20) {+ edges {+ node {+ name+ id+ url+ __typename+ }+ }+ }children(first: 20) {edges {node {