Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions graphene/types/decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def parse_literal(cls, node):

@staticmethod
def parse_value(value):
if value == "":
return None
try:
return _Decimal(value)
except ValueError:
Expand Down
7 changes: 7 additions & 0 deletions graphene/types/tests/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,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}