2828 is_union_type ,
2929 is_required_argument ,
3030)
31+ from ..pyutils import inspect
3132from ..utilities .assert_valid_name import is_valid_name_error
3233from ..utilities .type_comparators import is_equal_type , is_type_sub_type_of
3334from .directives import GraphQLDirective , is_directive
@@ -48,7 +49,7 @@ def validate_schema(schema: GraphQLSchema) -> List[GraphQLError]:
4849 """
4950 # First check to ensure the provided value is in fact a GraphQLSchema.
5051 if not is_schema (schema ):
51- raise TypeError (f"Expected { schema !r } to be a GraphQL schema." )
52+ raise TypeError (f"Expected { inspect ( schema ) } to be a GraphQL schema." )
5253
5354 # If this Schema has already been validated, return the previous results.
5455 # noinspection PyProtectedMember
@@ -140,7 +141,7 @@ def validate_directives(self):
140141 # Ensure all directives are in fact GraphQL directives.
141142 if not is_directive (directive ):
142143 self .report_error (
143- f"Expected directive but got: { directive !r } ." ,
144+ f"Expected directive but got: { inspect ( directive ) } ." ,
144145 getattr (directive , "ast_node" , None ),
145146 )
146147 continue
@@ -168,7 +169,7 @@ def validate_directives(self):
168169 if not is_input_type (arg .type ):
169170 self .report_error (
170171 f"The type of @{ directive .name } ({ arg_name } :)"
171- f" must be Input Type but got: { arg .type !r } ." ,
172+ f" must be Input Type but got: { inspect ( arg .type ) } ." ,
172173 get_directive_arg_type_node (directive , arg_name ),
173174 )
174175
@@ -192,7 +193,7 @@ def validate_types(self):
192193 # Ensure all provided types are in fact GraphQL type.
193194 if not is_named_type (type_ ):
194195 self .report_error (
195- f"Expected GraphQL named type but got: { type_ !r } ." ,
196+ f"Expected GraphQL named type but got: { inspect ( type ) } ." ,
196197 type_ .ast_node if type_ else None ,
197198 )
198199 continue
@@ -253,7 +254,7 @@ def validate_fields(self, type_: Union[GraphQLObjectType, GraphQLInterfaceType])
253254 if not is_output_type (field .type ):
254255 self .report_error (
255256 f"The type of { type_ .name } .{ field_name } "
256- " must be Output Type but got: {field.type!r }." ,
257+ " must be Output Type but got: {inspect( field.type) }." ,
257258 get_field_type_node (type_ , field_name ),
258259 )
259260
@@ -279,7 +280,7 @@ def validate_fields(self, type_: Union[GraphQLObjectType, GraphQLInterfaceType])
279280 self .report_error (
280281 "Field argument"
281282 f" { type_ .name } .{ field_name } ({ arg_name } :)"
282- f" must be Input Type but got: { arg .type !r } ." ,
283+ f" must be Input Type but got: { inspect ( arg .type ) } ." ,
283284 get_field_arg_type_node (type_ , field_name , arg_name ),
284285 )
285286
@@ -289,7 +290,7 @@ def validate_object_interfaces(self, obj: GraphQLObjectType):
289290 if not is_interface_type (iface ):
290291 self .report_error (
291292 f"Type { obj .name } must only implement Interface"
292- f" types, it cannot implement { iface !r } ." ,
293+ f" types, it cannot implement { inspect ( iface ) } ." ,
293294 get_implements_interface_node (obj , iface ),
294295 )
295296 continue
@@ -450,7 +451,7 @@ def validate_input_fields(self, input_obj: GraphQLInputObjectType):
450451 if not is_input_type (field .type ):
451452 self .report_error (
452453 f"The type of { input_obj .name } .{ field_name } "
453- f" must be Input Type but got: { field .type !r } ." ,
454+ f" must be Input Type but got: { inspect ( field .type ) } ." ,
454455 field .ast_node .type if field .ast_node else None ,
455456 )
456457
0 commit comments