Skip to content
Merged
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
4 changes: 2 additions & 2 deletions graphene/types/decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from decimal import Decimal as _Decimal

from graphql.language.ast import StringValueNode
from graphql.language.ast import StringValueNode, IntValueNode

from .scalars import Scalar

Expand All @@ -23,7 +23,7 @@ def serialize(dec):

@classmethod
def parse_literal(cls, node):
if isinstance(node, StringValueNode):
if isinstance(node, (StringValueNode, IntValueNode)):
return cls.parse_value(node.value)

@staticmethod
Expand Down
8 changes: 8 additions & 0 deletions graphene/types/tests/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,11 @@ def test_bad_decimal_query():
result = schema.execute("""{ decimal(input: "%s") }""" % not_a_decimal)
assert len(result.errors) == 1
assert result.data is None


def test_decimal_string_query_integer():
decimal_value = 1
result = schema.execute("""{ decimal(input: %s) }""" % decimal_value)
assert not result.errors
assert result.data == {"decimal": str(decimal_value)}
assert decimal.Decimal(result.data["decimal"]) == decimal_value
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ deps =
setenv =
PYTHONPATH = .:{envdir}
commands =
py{36,37}: pytest --cov=graphene graphene examples {posargs}
py{36,37,38}: pytest --cov=graphene graphene examples {posargs}

[testenv:pre-commit]
basepython=python3.7
Expand Down