@@ -24,6 +24,8 @@ import {
24
24
import { __Schema } from './introspection' ;
25
25
import {
26
26
GraphQLDirective ,
27
+ GraphQLStreamDirective ,
28
+ GraphQLDeferDirective ,
27
29
isDirective ,
28
30
specifiedDirectives ,
29
31
} from './directives' ;
@@ -136,6 +138,7 @@ export class GraphQLSchema {
136
138
__validationErrors : ?$ReadOnlyArray < GraphQLError > ;
137
139
// Referenced by execute()
138
140
__experimentalDeferFragmentSpreads : boolean ;
141
+ __experimentalStream : boolean ;
139
142
140
143
constructor ( config : $ReadOnly < GraphQLSchemaConfig > ) : void {
141
144
// If this schema was built from a source known to be valid, then it may be
@@ -163,14 +166,27 @@ export class GraphQLSchema {
163
166
this . astNode = config . astNode ;
164
167
this . extensionASTNodes = config . extensionASTNodes ;
165
168
166
- this . __experimentalDeferFragmentSpreads =
167
- config . experimentalDeferFragmentSpreads || false ;
169
+ this . __experimentalStream = config . experimentalStream || false ;
168
170
this . _queryType = config . query ;
169
171
this . _mutationType = config . mutation ;
170
172
this . _subscriptionType = config . subscription ;
171
173
// Provide specified directives (e.g. @include and @skip) by default.
172
174
this . _directives = config . directives || specifiedDirectives ;
173
175
176
+ if ( config . experimentalDeferFragmentSpreads ) {
177
+ this . __experimentalDeferFragmentSpreads = true ;
178
+ this . _directives = [ ] . concat ( this . _directives , [ GraphQLDeferDirective ] ) ;
179
+ } else {
180
+ this . __experimentalDeferFragmentSpreads = false ;
181
+ }
182
+
183
+ if ( config . experimentalStream ) {
184
+ this . __experimentalStream = true ;
185
+ this . _directives = [ ] . concat ( this . _directives , [ GraphQLStreamDirective ] ) ;
186
+ } else {
187
+ this . __experimentalStream = false ;
188
+ }
189
+
174
190
// Build type map now to detect any errors within this schema.
175
191
const initialTypes : Array < ?GraphQLNamedType > = [
176
192
this . _queryType ,
@@ -320,6 +336,18 @@ export type GraphQLSchemaValidationOptions = {|
320
336
* Default: false
321
337
*/
322
338
experimentalDeferFragmentSpreads ?: boolean ,
339
+
340
+ /**
341
+ *
342
+ * EXPERIMENTAL:
343
+ *
344
+ * If enabled, items from a plural fields with @stream directive
345
+ * are not returned from the iniital query and each item is returned
346
+ * in a patch after the initial result from the synchronous query.
347
+ *
348
+ * Default: false
349
+ */
350
+ experimentalStream ?: boolean ,
323
351
| } ;
324
352
325
353
export type GraphQLSchemaConfig = { |
0 commit comments