File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -987,14 +987,25 @@ describe('extendSchema', () => {
987
987
hearSomething: String
988
988
}
989
989
` ) ;
990
- const schema = extendSchema ( testSchema , ast ) ;
991
- expect ( schema . extensionASTNodes . map ( print ) . join ( '\n' ) ) . to . equal ( dedent `
990
+ let schema = extendSchema ( testSchema , ast ) ;
991
+
992
+ const secondAST = parse ( `
993
+ extend schema @foo
994
+
995
+ directive @foo on SCHEMA
996
+ ` ) ;
997
+ schema = extendSchema ( schema , secondAST ) ;
998
+
999
+ const nodes = schema . extensionASTNodes ;
1000
+ expect ( nodes . map ( n => print ( n ) + '\n' ) . join ( '' ) ) . to . equal ( dedent `
992
1001
extend schema {
993
1002
mutation: Mutation
994
1003
}
995
1004
extend schema {
996
1005
subscription: Subscription
997
- }` ) ;
1006
+ }
1007
+ extend schema @foo
1008
+ ` ) ;
998
1009
} ) ;
999
1010
1000
1011
it ( 'does not allow redefining an existing root type' , ( ) => {
Original file line number Diff line number Diff line change @@ -222,6 +222,12 @@ export function extendSchema(
222
222
}
223
223
} ) ;
224
224
225
+ const schemaExtensionASTNodes = schemaExtensions
226
+ ? schema . extensionASTNodes
227
+ ? schema . extensionASTNodes . concat ( schemaExtensions )
228
+ : schemaExtensions
229
+ : schema . extensionASTNodes ;
230
+
225
231
const types = [
226
232
// Iterate through all types, getting the type definition for each, ensuring
227
233
// that any type not directly referenced by a field will get created.
@@ -246,7 +252,7 @@ export function extendSchema(
246
252
types,
247
253
directives : getMergedDirectives ( ) ,
248
254
astNode : schema . astNode ,
249
- extensionASTNodes : schemaExtensions ,
255
+ extensionASTNodes : schemaExtensionASTNodes ,
250
256
allowedLegacyNames,
251
257
} ) ;
252
258
You can’t perform that action at this time.
0 commit comments