Skip to content

Commit 9d304f9

Browse files
committed
Minor simplification in ast_from_value
1 parent 8403951 commit 9d304f9

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

graphql/utils/ast_from_value.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import json
2-
import re
32
import sys
43

54
from six import string_types
@@ -12,6 +11,7 @@
1211
GraphQLNonNull,
1312
)
1413
from ..type.scalars import GraphQLFloat
14+
from .assert_valid_name import COMPILED_NAME_PATTERN
1515

1616

1717
def ast_from_value(value, type=None):
@@ -45,9 +45,7 @@ def ast_from_value(value, type=None):
4545
return ast.FloatValue(string_num)
4646

4747
if isinstance(value, string_types):
48-
if isinstance(type, GraphQLEnumType) and re.match(
49-
r"^[_a-zA-Z][_a-zA-Z0-9]*$", value
50-
):
48+
if isinstance(type, GraphQLEnumType) and COMPILED_NAME_PATTERN.match(value):
5149
return ast.EnumValue(value)
5250

5351
return ast.StringValue(json.dumps(value)[1:-1])

0 commit comments

Comments
 (0)