File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,17 @@ describe('extendSchema', () => {
113113 expect ( extendedSchema . getDirectives ( ) ) . to . have . members ( specifiedDirectives ) ;
114114 } ) ;
115115
116+ it ( 'preserves original schema config' , ( ) => {
117+ const description = 'A schema description' ;
118+ const extensions = Object . freeze ( { foo : 'bar' } ) ;
119+ const schema = new GraphQLSchema ( { description, extensions } ) ;
120+
121+ const extendedSchema = extendSchema ( schema , parse ( 'scalar Bar' ) ) ;
122+
123+ expect ( extendedSchema . description ) . to . equal ( description ) ;
124+ expect ( extendedSchema . extensions ) . to . deep . equal ( extensions ) ;
125+ } ) ;
126+
116127 it ( 'extends objects by adding new fields' , ( ) => {
117128 const schema = buildSchema ( `
118129 type Query {
Original file line number Diff line number Diff line change @@ -239,14 +239,14 @@ export function extendSchemaImpl(
239239
240240 // Then produce and return a Schema config with these types.
241241 return {
242- description : schemaDef ?. description ?. value ,
242+ description : schemaDef ?. description ?. value ?? schemaConfig . description ,
243243 ...operationTypes ,
244244 types : Object . values ( typeMap ) ,
245245 directives : [
246246 ...schemaConfig . directives . map ( replaceDirective ) ,
247247 ...directiveDefs . map ( buildDirective ) ,
248248 ] ,
249- extensions : Object . create ( null ) ,
249+ extensions : schemaConfig . extensions ,
250250 astNode : schemaDef ?? schemaConfig . astNode ,
251251 extensionASTNodes : schemaConfig . extensionASTNodes . concat ( schemaExtensions ) ,
252252 assumeValid : options ?. assumeValid ?? false ,
You can’t perform that action at this time.
0 commit comments