diff --git a/graphene/types/schema.py b/graphene/types/schema.py index 6a1af687..99532354 100644 --- a/graphene/types/schema.py +++ b/graphene/types/schema.py @@ -26,7 +26,6 @@ from graphql import ( GraphQLObjectType, GraphQLSchema, GraphQLString, - Undefined, ) from graphql.execution import ExecutionContext from graphql.execution.values import get_argument_values diff --git a/graphene/types/tests/test_type_map.py b/graphene/types/tests/test_type_map.py index 334eb241..79572916 100644 --- a/graphene/types/tests/test_type_map.py +++ b/graphene/types/tests/test_type_map.py @@ -6,6 +6,7 @@ from graphql.type import ( GraphQLInputField, GraphQLInputObjectType, GraphQLInterfaceType, + GraphQLNonNull, GraphQLObjectType, GraphQLString, ) @@ -94,6 +95,23 @@ def test_objecttype(): } +def test_required_argument_with_default_value(): + class MyObjectType(ObjectType): + foo = String( + bar=String(required=True, default_value="x") + ) + + type_map = create_type_map([MyObjectType]) + + graphql_type = type_map["MyObjectType"] + foo_field = graphql_type.fields["foo"] + + bar_argument = foo_field.args["bar"] + assert bar_argument.default_value == "x" + assert isinstance(bar_argument.type, GraphQLNonNull) + assert bar_argument.type.of_type == GraphQLString + + def test_dynamic_objecttype(): class MyObjectType(ObjectType): """Description"""