@@ -16,6 +16,8 @@ import {
16
16
GraphQLSkipDirective ,
17
17
GraphQLIncludeDirective ,
18
18
GraphQLDeprecatedDirective ,
19
+ GraphQLStreamDirective ,
20
+ GraphQLDeferDirective ,
19
21
} from '../../type/directives' ;
20
22
import {
21
23
GraphQLID ,
@@ -220,20 +222,30 @@ describe('Schema Builder', () => {
220
222
} ) ;
221
223
222
224
it ( 'Overriding directives excludes specified' , ( ) => {
223
- const schema = buildSchema ( `
225
+ const schema = buildSchema (
226
+ `
224
227
directive @skip on FIELD
225
228
directive @include on FIELD
226
229
directive @deprecated on FIELD_DEFINITION
227
- ` ) ;
230
+ directive @defer on FRAGMENT_SPREAD
231
+ directive @stream on FIELD
232
+ ` ,
233
+ {
234
+ experimentalStream : true ,
235
+ experimentalDefer : true ,
236
+ } ,
237
+ ) ;
228
238
229
- expect ( schema . getDirectives ( ) ) . to . have . lengthOf ( 3 ) ;
239
+ expect ( schema . getDirectives ( ) ) . to . have . lengthOf ( 5 ) ;
230
240
expect ( schema . getDirective ( 'skip' ) ) . to . not . equal ( GraphQLSkipDirective ) ;
231
241
expect ( schema . getDirective ( 'include' ) ) . to . not . equal (
232
242
GraphQLIncludeDirective ,
233
243
) ;
234
244
expect ( schema . getDirective ( 'deprecated' ) ) . to . not . equal (
235
245
GraphQLDeprecatedDirective ,
236
246
) ;
247
+ expect ( schema . getDirective ( 'defer' ) ) . to . not . equal ( GraphQLDeferDirective ) ;
248
+ expect ( schema . getDirective ( 'stream' ) ) . to . not . equal ( GraphQLStreamDirective ) ;
237
249
} ) ;
238
250
239
251
it ( 'Adding directives maintains @skip & @include' , ( ) => {
@@ -247,6 +259,22 @@ describe('Schema Builder', () => {
247
259
expect ( schema . getDirective ( 'deprecated' ) ) . to . not . equal ( undefined ) ;
248
260
} ) ;
249
261
262
+ it ( 'Adds @stream and @defer when experimental flags are passed to schema' , ( ) => {
263
+ const schema = buildSchema ( 'type Query' , {
264
+ experimentalStream : true ,
265
+ experimentalDefer : true ,
266
+ } ) ;
267
+
268
+ expect ( schema . getDirectives ( ) ) . to . have . lengthOf ( 5 ) ;
269
+ expect ( schema . getDirective ( 'stream' ) ) . to . equal ( GraphQLStreamDirective ) ;
270
+ expect ( schema . getDirective ( 'defer' ) ) . to . equal ( GraphQLDeferDirective ) ;
271
+ expect ( schema . getDirective ( 'skip' ) ) . to . equal ( GraphQLSkipDirective ) ;
272
+ expect ( schema . getDirective ( 'include' ) ) . to . equal ( GraphQLIncludeDirective ) ;
273
+ expect ( schema . getDirective ( 'deprecated' ) ) . to . equal (
274
+ GraphQLDeprecatedDirective ,
275
+ ) ;
276
+ } ) ;
277
+
250
278
it ( 'Type modifiers' , ( ) => {
251
279
const sdl = dedent `
252
280
type Query {
0 commit comments