diff --git a/graphene/types/decimal.py b/graphene/types/decimal.py index 69952f96..25277000 100644 --- a/graphene/types/decimal.py +++ b/graphene/types/decimal.py @@ -28,6 +28,8 @@ class Decimal(Scalar): @staticmethod def parse_value(value): + if value == "": + return None try: return _Decimal(value) except Exception: diff --git a/graphene/types/tests/test_decimal.py b/graphene/types/tests/test_decimal.py index 1ba48bd1..4662c064 100644 --- a/graphene/types/tests/test_decimal.py +++ b/graphene/types/tests/test_decimal.py @@ -66,3 +66,10 @@ def test_decimal_string_query_integer(): assert not result.errors assert result.data == {"decimal": str(decimal_value)} assert decimal.Decimal(result.data["decimal"]) == decimal_value + +def test_parse_decimal_empty_string(): + """Parsing an empty string should return None""" + result = schema.execute("""{ decimal(input: \"\") }""") + assert not result.errors + assert result.data == {"decimal": None} +