22
33from ..language .printer import print_ast
44from ..utils .ast_from_value import ast_from_value
5+ from ..utils .undefined import UndefinedDefaultValue
56from .definition import (GraphQLArgument , GraphQLEnumType , GraphQLEnumValue ,
67 GraphQLField , GraphQLInputObjectType ,
78 GraphQLInterfaceType , GraphQLList , GraphQLNonNull ,
@@ -333,6 +334,15 @@ def input_fields(type, info):
333334 ])
334335)
335336
337+
338+ def _resolve_default_value (input_value , * _ ):
339+ if input_value .default_value is UndefinedDefaultValue :
340+ return UndefinedDefaultValue
341+ if input_value .default_value is None :
342+ return None
343+ return print_ast (ast_from_value (input_value .default_value , input_value ))
344+
345+
336346__InputValue = GraphQLObjectType (
337347 '__InputValue' ,
338348 description = 'Arguments provided to Fields or Directives and the input fields of an '
@@ -344,9 +354,7 @@ def input_fields(type, info):
344354 ('type' , GraphQLField (GraphQLNonNull (__Type ))),
345355 ('defaultValue' , GraphQLField (
346356 type = GraphQLString ,
347- resolver = lambda input_val , * _ :
348- None if input_val .default_value is None
349- else print_ast (ast_from_value (input_val .default_value , input_val ))
357+ resolver = _resolve_default_value ,
350358 ))
351359 ]))
352360
0 commit comments