diff --git a/graphql/utils/ast_from_value.py b/graphql/utils/ast_from_value.py index 6773423b..05da84a7 100644 --- a/graphql/utils/ast_from_value.py +++ b/graphql/utils/ast_from_value.py @@ -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])