Skip to content
Open
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
7 changes: 4 additions & 3 deletions graphql/utils/ast_from_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ def ast_from_value(value, type=None):
return ast.FloatValue(string_num)

if isinstance(value, string_types):
if isinstance(type, GraphQLEnumType) and re.match(
r"^[_a-zA-Z][_a-zA-Z0-9]*$", value
):
if (
isinstance(type, GraphQLEnumType)
or ("type" in dir(type) and isinstance(type.type, GraphQLEnumType))
) and re.match(r"^[_a-zA-Z][_a-zA-Z0-9]*$", value):
return ast.EnumValue(value)

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