diff --git a/src/graphql/utilities/extend_schema.py b/src/graphql/utilities/extend_schema.py index 906383e7..ffa2420e 100644 --- a/src/graphql/utilities/extend_schema.py +++ b/src/graphql/utilities/extend_schema.py @@ -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), diff --git a/tests/utilities/test_extend_schema.py b/tests/utilities/test_extend_schema.py index 9ce77071..9afd707e 100644 --- a/tests/utilities/test_extend_schema.py +++ b/tests/utilities/test_extend_schema.py @@ -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( '''