Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix remove file field form QraphQL API mutation
fowczarek77dd4288ef89
diff --git a/saleor/graphql/core/mutations.py b/saleor/graphql/core/mutations.pyindex 7d378ba2c4..b7e8b261f4 100644--- a/saleor/graphql/core/mutations.py+++ b/saleor/graphql/core/mutations.py@@ -3,6 +3,7 @@ from textwrap import dedentimport graphenefrom django.core.exceptions import ImproperlyConfigured, ValidationError+from django.db.models.fields.files import FileFieldfrom graphene.types.mutation import MutationOptionsfrom graphene_django.registry import get_global_registryfrom graphql.error import GraphQLError@@ -137,8 +138,15 @@ class BaseMutation(graphene.Mutation):f.name not in cleaned_data]):continuedata = cleaned_data[f.name]- if not f.null and data is None:- data = f._get_default()+ if data is None:+ # We want to reset the file field value when None was passed+ # in the input, but `FileField.save_form_data` ignores None+ # values. In that case we manually pass False which clears+ # the file.+ if isinstance(f, FileField):+ data = False+ if not f.null:+ data = f._get_default()f.save_form_data(instance, data)return instance