Skip to content

Commit

Permalink
extend_schema: preserve "description" and "extensions"
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Feb 15, 2024
1 parent 551c6c4 commit 7987576
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/graphql/utilities/extend_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,13 @@ def extend_schema_args(
for directive in schema_kwargs["directives"]
)
+ tuple(self.build_directive(directive) for directive in directive_defs),
description=schema_def.description.value
if schema_def and schema_def.description
else None,
extensions={},
description=(
schema_def.description.value
if schema_def and schema_def.description
else None
)
or schema_kwargs["description"],
extensions=schema_kwargs["extensions"],
ast_node=schema_def or schema_kwargs["ast_node"],
extension_ast_nodes=schema_kwargs["extension_ast_nodes"]
+ tuple(schema_extensions),
Expand Down
10 changes: 10 additions & 0 deletions tests/utilities/test_extend_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ def does_not_modify_built_in_types_and_directives():

assert extended_schema.directives == specified_directives

def preserves_original_schema_config():
description = "A schema description"
extensions = {"foo": "bar"}
schema = GraphQLSchema(description=description, extensions=extensions)

extended_schema = extend_schema(schema, parse("scalar Bar"))

assert extended_schema.description == description
assert extended_schema.extensions is extensions

def extends_objects_by_adding_new_fields():
schema = build_schema(
'''
Expand Down

0 comments on commit 7987576

Please sign in to comment.