This repository was archived by the owner on Feb 6, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
tests/schema_transformation_tests Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -1116,6 +1116,9 @@ def enter_field_definition(
1116
1116
# Therefore, we don't need to explicitly suppress the field as well and this should not
1117
1117
# raise errors.
1118
1118
return IDLE
1119
+ if self .field_renamings .get (self .current_type , {}).get (field_name , {field_name }) == set ():
1120
+ # Field was also suppressed so this should not raise errors.
1121
+ return IDLE
1119
1122
if self .current_type not in self .fields_to_suppress :
1120
1123
self .fields_to_suppress [self .current_type ] = {}
1121
1124
self .fields_to_suppress [self .current_type ][field_name ] = field_type
Original file line number Diff line number Diff line change @@ -1140,6 +1140,45 @@ def test_field_still_depends_on_suppressed_type(self) -> None:
1140
1140
parse (ISS .multiple_fields_schema ), {"Dog" : None }, {}
1141
1141
) # The type named Human contains a field of type Dog.
1142
1142
1143
+ def test_suppress_field_prevent_cascading_suppression_error (self ) -> None :
1144
+ renamed_schema = rename_schema (
1145
+ parse (ISS .multiple_fields_schema ), {"Dog" : None }, {"Human" : {"pet" : set ()}}
1146
+ )
1147
+ renamed_schema_string = dedent (
1148
+ """\
1149
+ schema {
1150
+ query: SchemaQuery
1151
+ }
1152
+
1153
+ directive @output(
1154
+ \" \" \" What to designate the output field generated from this property field.\" \" \"
1155
+ out_name: String!
1156
+ ) on FIELD
1157
+
1158
+ type Human {
1159
+ id: String
1160
+ name: String
1161
+ age: Int
1162
+ droid: Droid
1163
+ }
1164
+
1165
+ type Droid {
1166
+ id: String
1167
+ model: String
1168
+ }
1169
+
1170
+ type SchemaQuery {
1171
+ Human: Human
1172
+ Droid: Droid
1173
+ }
1174
+ """
1175
+ )
1176
+ compare_schema_texts_order_independently (
1177
+ self , renamed_schema_string , print_ast (renamed_schema .schema_ast )
1178
+ )
1179
+ self .assertEqual ({}, renamed_schema .reverse_name_map )
1180
+ self .assertEqual ({}, renamed_schema .reverse_field_name_map )
1181
+
1143
1182
def test_field_of_suppressed_type_in_suppressed_type (self ) -> None :
1144
1183
# The schema contains an object type that contains a field of the type Human. Normally,
1145
1184
# suppressing the type named Human would cause a CascadingSuppressionError because the
You can’t perform that action at this time.
0 commit comments