File tree 3 files changed +11
-3
lines changed
3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
from decimal import Decimal as _Decimal
4
4
5
- from graphql .language .ast import StringValueNode
5
+ from graphql .language .ast import StringValueNode , IntValueNode
6
6
7
7
from .scalars import Scalar
8
8
@@ -23,7 +23,7 @@ def serialize(dec):
23
23
24
24
@classmethod
25
25
def parse_literal (cls , node ):
26
- if isinstance (node , StringValueNode ):
26
+ if isinstance (node , ( StringValueNode , IntValueNode ) ):
27
27
return cls .parse_value (node .value )
28
28
29
29
@staticmethod
Original file line number Diff line number Diff line change @@ -41,3 +41,11 @@ def test_bad_decimal_query():
41
41
result = schema .execute ("""{ decimal(input: "%s") }""" % not_a_decimal )
42
42
assert len (result .errors ) == 1
43
43
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 8
8
setenv =
9
9
PYTHONPATH = .:{envdir}
10
10
commands =
11
- py{36,37}: pytest --cov =graphene graphene examples {posargs}
11
+ py{36,37,38 }: pytest --cov =graphene graphene examples {posargs}
12
12
13
13
[testenv:pre-commit]
14
14
basepython =python3.7
You can’t perform that action at this time.
0 commit comments