Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Set homepage collection to None in api if input field is null
oldPadavan602cc85d9b96
diff --git a/saleor/graphql/shop/mutations.py b/saleor/graphql/shop/mutations.pyindex 8d96b0e433..983416b6a4 100644--- a/saleor/graphql/shop/mutations.py+++ b/saleor/graphql/shop/mutations.py@@ -93,10 +93,12 @@ class HomepageCollectionUpdate(BaseMutation):@classmethod@permission_required('site.manage_settings')- def mutate(cls, root, info, collection):+ def mutate(cls, root, info, collection=None):errors = []- new_collection = cls.get_node_or_error(- info, collection, errors, 'collection', Collection)+ new_collection = None+ if collection:+ new_collection = cls.get_node_or_error(+ info, collection, errors, 'collection', Collection)if errors:return HomepageCollectionUpdate(errors=errors)site_settings = info.context.site.settingsdiff --git a/tests/api/test_shop.py b/tests/api/test_shop.pyindex d902d9dde9..ee980404b3 100644--- a/tests/api/test_shop.py+++ b/tests/api/test_shop.py@@ -242,6 +242,32 @@ def test_homepage_collection_update(assert site.settings.homepage_collection == collection+def test_homepage_collection_update_set_null(+ staff_api_client, collection, site_settings,+ permission_manage_settings):+ query = """+ mutation homepageCollectionUpdate($collection: ID) {+ homepageCollectionUpdate(collection: $collection) {+ shop {+ homepageCollection {+ id+ }+ }+ }+ }+ """+ site_settings.homepage_collection = collection+ site_settings.save()+ variables = {'collection': None}+ response = staff_api_client.post_graphql(+ query, variables, permissions=[permission_manage_settings])+ content = get_graphql_content(response)+ data = content['data']['homepageCollectionUpdate']['shop']+ assert data['homepageCollection'] is None+ site_settings.refresh_from_db()+ assert site_settings.homepage_collection is None++def test_query_default_country(user_api_client, settings):settings.DEFAULT_COUNTRY = 'US'query = """