From df22d12a9548c0b88dc1cfb92940040583047ee4 Mon Sep 17 00:00:00 2001 From: Scott Schreckengaust Date: Tue, 19 Feb 2019 13:35:55 -0800 Subject: [PATCH 1/3] Add type.type to return Looking into graphene's Argument defaut_value when it is an enumeration. --- graphql/utils/ast_from_value.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphql/utils/ast_from_value.py b/graphql/utils/ast_from_value.py index 6773423b..7f9e6291 100644 --- a/graphql/utils/ast_from_value.py +++ b/graphql/utils/ast_from_value.py @@ -45,7 +45,7 @@ def ast_from_value(value, type=None): return ast.FloatValue(string_num) if isinstance(value, string_types): - if isinstance(type, GraphQLEnumType) and re.match( + 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) From 67c017654f3696d9df344c3ea105947006832070 Mon Sep 17 00:00:00 2001 From: Scott Schreckengaust Date: Tue, 19 Feb 2019 13:48:58 -0800 Subject: [PATCH 2/3] Update to `black` Reformat code --- graphql/utils/ast_from_value.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/graphql/utils/ast_from_value.py b/graphql/utils/ast_from_value.py index 7f9e6291..94a0037b 100644 --- a/graphql/utils/ast_from_value.py +++ b/graphql/utils/ast_from_value.py @@ -45,7 +45,8 @@ def ast_from_value(value, type=None): return ast.FloatValue(string_num) if isinstance(value, string_types): - if (isinstance(type, GraphQLEnumType) or ('type' in dir(type) and isinstance(type.type, GraphQLEnumType))) and re.match( + 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) From 8b509943f9cccbd96492a1686a3ad2f77ec2cfc0 Mon Sep 17 00:00:00 2001 From: Scott Schreckengaust Date: Tue, 19 Feb 2019 16:28:36 -0800 Subject: [PATCH 3/3] fixed `black` This is a trial to check the `black` failure. --- graphql/utils/ast_from_value.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/graphql/utils/ast_from_value.py b/graphql/utils/ast_from_value.py index 94a0037b..05da84a7 100644 --- a/graphql/utils/ast_from_value.py +++ b/graphql/utils/ast_from_value.py @@ -45,10 +45,10 @@ def ast_from_value(value, type=None): return ast.FloatValue(string_num) if isinstance(value, string_types): - 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 - ): + 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])