Skip to content

Commit 67ce461

Browse files
committed
build_client_schema: Revert breaking change
Replicates graphql/graphql-js@3c79bed
1 parent c9188c5 commit 67ce461

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

graphql/utilities/build_client_schema.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,7 @@ def build_directive(directive_introspection: Dict) -> GraphQLDirective:
312312
for std_type_name, std_type in chain(
313313
specified_scalar_types.items(), introspection_types.items()
314314
):
315-
if std_type_name in type_map:
316-
type_map[std_type_name] = std_type
315+
type_map[std_type_name] = std_type
317316

318317
# Get the root Query, Mutation, and Subscription types.
319318

tests/utilities/test_build_client_schema.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,25 @@ def cycle_introspection(sdl_string):
3838
# If the client then runs the introspection query against the client-side schema,
3939
# it should get a result identical to what was returned by the server
4040
second_introspection = introspection_from_schema(client_schema)
41+
42+
hack_to_remove_standard_types(second_introspection)
43+
hack_to_remove_standard_types(initial_introspection)
44+
45+
# If the client then runs the introspection query against the client-side
46+
# schema, it should get a result identical to what was returned by the server.
4147
assert initial_introspection == second_introspection
4248
return print_schema(client_schema)
4349

4450

51+
# Temporary hack to remove always presented standard types - should be removed in 15.0
52+
def hack_to_remove_standard_types(introspection):
53+
introspection["__schema"]["types"] = [
54+
type_
55+
for type_ in introspection["__schema"]["types"]
56+
if type_["name"] not in ("ID", "Float", "Int", "Boolean", "String")
57+
]
58+
59+
4560
def describe_type_system_build_schema_from_introspection():
4661
def builds_a_simple_schema():
4762
sdl = dedent(
@@ -311,6 +326,9 @@ def builds_a_schema_with_an_enum():
311326
introspection = introspection_from_schema(schema)
312327
client_schema = build_client_schema(introspection)
313328
second_introspection = introspection_from_schema(client_schema)
329+
330+
hack_to_remove_standard_types(second_introspection)
331+
hack_to_remove_standard_types(introspection)
314332
assert second_introspection == introspection
315333

316334
client_food_enum = client_schema.get_type("Food")

0 commit comments

Comments
 (0)