File tree 2 files changed +13
-2
lines changed
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,17 @@ describe('extendSchema', () => {
113
113
expect ( extendedSchema . getDirectives ( ) ) . to . have . members ( specifiedDirectives ) ;
114
114
} ) ;
115
115
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
+
116
127
it ( 'extends objects by adding new fields' , ( ) => {
117
128
const schema = buildSchema ( `
118
129
type Query {
Original file line number Diff line number Diff line change @@ -239,14 +239,14 @@ export function extendSchemaImpl(
239
239
240
240
// Then produce and return a Schema config with these types.
241
241
return {
242
- description : schemaDef ?. description ?. value ,
242
+ description : schemaDef ?. description ?. value ?? schemaConfig . description ,
243
243
...operationTypes ,
244
244
types : Object . values ( typeMap ) ,
245
245
directives : [
246
246
...schemaConfig . directives . map ( replaceDirective ) ,
247
247
...directiveDefs . map ( buildDirective ) ,
248
248
] ,
249
- extensions : Object . create ( null ) ,
249
+ extensions : schemaConfig . extensions ,
250
250
astNode : schemaDef ?? schemaConfig . astNode ,
251
251
extensionASTNodes : schemaConfig . extensionASTNodes . concat ( schemaExtensions ) ,
252
252
assumeValid : options ?. assumeValid ?? false ,
You can’t perform that action at this time.
0 commit comments