File tree Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 22
33from decimal import Decimal as _Decimal
44
5- from graphql .language .ast import StringValueNode
5+ from graphql .language .ast import StringValueNode , IntValueNode
66
77from .scalars import Scalar
88
@@ -23,7 +23,7 @@ def serialize(dec):
2323
2424 @classmethod
2525 def parse_literal (cls , node ):
26- if isinstance (node , StringValueNode ):
26+ if isinstance (node , ( StringValueNode , IntValueNode ) ):
2727 return cls .parse_value (node .value )
2828
2929 @staticmethod
Original file line number Diff line number Diff line change @@ -41,3 +41,11 @@ def test_bad_decimal_query():
4141 result = schema .execute ("""{ decimal(input: "%s") }""" % not_a_decimal )
4242 assert len (result .errors ) == 1
4343 assert result .data is None
44+
45+
46+ def test_decimal_string_query_integer ():
47+ decimal_value = 1
48+ result = schema .execute ("""{ decimal(input: %s) }""" % decimal_value )
49+ assert not result .errors
50+ assert result .data == {"decimal" : str (decimal_value )}
51+ assert decimal .Decimal (result .data ["decimal" ]) == decimal_value
Original file line number Diff line number Diff line change 88setenv =
99 PYTHONPATH = .:{envdir}
1010commands =
11- py{36,37}: pytest --cov =graphene graphene examples {posargs}
11+ py{36,37,38 }: pytest --cov =graphene graphene examples {posargs}
1212
1313[testenv:pre-commit]
1414basepython =python3.7
You can’t perform that action at this time.
0 commit comments