@@ -283,7 +283,7 @@ def _validate_renamings(
283
283
type implementing an interface
284
284
"""
285
285
_ensure_no_cascading_type_suppressions (schema_ast , type_renamings , field_renamings , query_type )
286
- _ensure_no_unsupported_operations (schema_ast , type_renamings )
286
+ _ensure_no_unsupported_suppressions (schema_ast , type_renamings )
287
287
288
288
289
289
def _ensure_no_cascading_type_suppressions (
@@ -339,29 +339,6 @@ def _ensure_no_cascading_type_suppressions(
339
339
raise CascadingSuppressionError ("\n " .join (error_message_components ))
340
340
341
341
342
- def _ensure_no_unsupported_operations (
343
- schema_ast : DocumentNode ,
344
- type_renamings : Mapping [str , Optional [str ]],
345
- ) -> None :
346
- """Check for unsupported type renaming or suppression operations."""
347
- _ensure_no_unsupported_scalar_operations (type_renamings )
348
- _ensure_no_unsupported_suppressions (schema_ast , type_renamings )
349
-
350
-
351
- def _ensure_no_unsupported_scalar_operations (
352
- type_renamings : Mapping [str , Optional [str ]],
353
- ) -> None :
354
- """Check for unsupported scalar operations."""
355
- unsupported_scalar_operations = {
356
- scalar_name for scalar_name in builtin_scalar_type_names if scalar_name in type_renamings
357
- }
358
- if unsupported_scalar_operations :
359
- raise NotImplementedError (
360
- f"Type_renamings contained renamings for the following built-in scalar types: "
361
- f"{ unsupported_scalar_operations } . To fix this, remove them from type_renamings."
362
- )
363
-
364
-
365
342
def _ensure_no_unsupported_suppressions (
366
343
schema_ast : DocumentNode , type_renamings : Mapping [str , Optional [str ]]
367
344
) -> None :
@@ -489,6 +466,12 @@ def _rename_and_suppress_types_and_fields(
489
466
f"they exist for the following types and should be removed: "
490
467
f"{ visitor .types_involving_interfaces_with_field_renamings } "
491
468
)
469
+ if visitor .illegal_builtin_scalar_renamings :
470
+ raise NotImplementedError (
471
+ f"Type_renamings contained renamings for the following built-in scalar types: "
472
+ f"{ visitor .illegal_builtin_scalar_renamings } . To fix this, remove them from "
473
+ f"type_renamings."
474
+ )
492
475
for type_name in visitor .suppressed_type_names :
493
476
if type_name not in type_renamings :
494
477
raise AssertionError (
@@ -642,6 +625,11 @@ class RenameSchemaTypesVisitor(Visitor):
642
625
# "Foo" to "String"
643
626
type_renamed_to_builtin_scalar_conflicts : Dict [str , str ]
644
627
628
+ # Collects naming errors that arise from attempting to rename a builtin scalar. If
629
+ # type_renamings["String"] == "Foo" schema, illegal_builtin_scalar_renamings will contain
630
+ # "String"
631
+ illegal_builtin_scalar_renamings : Set [str ]
632
+
645
633
# reverse_name_map maps renamed type name to original type name, containing all non-suppressed
646
634
# types, including those that were unchanged. Must contain unchanged names to prevent type
647
635
# renaming conflicts and raise SchemaRenameNameConflictError when they arise
@@ -717,6 +705,11 @@ def __init__(
717
705
self .reverse_name_map = {}
718
706
self .type_name_conflicts = {}
719
707
self .type_renamed_to_builtin_scalar_conflicts = {}
708
+ self .illegal_builtin_scalar_renamings = {
709
+ scalar_name
710
+ for scalar_name in builtin_scalar_type_names
711
+ if scalar_name in type_renamings
712
+ }
720
713
self .invalid_type_names = {}
721
714
self .query_type = query_type
722
715
self .suppressed_type_names = set ()
@@ -754,6 +747,7 @@ def _rename_or_suppress_or_ignore_name_and_add_to_record(
754
747
return IDLE
755
748
756
749
desired_type_name = self .type_renamings .get (type_name , type_name ) # Default use original
750
+
757
751
if desired_type_name is None :
758
752
# Suppress the type
759
753
self .suppressed_type_names .add (type_name )
0 commit comments