@@ -24,6 +24,8 @@ import {
2424import { __Schema } from './introspection' ;
2525import {
2626 GraphQLDirective ,
27+ GraphQLStreamDirective ,
28+ GraphQLDeferDirective ,
2729 isDirective ,
2830 specifiedDirectives ,
2931} from './directives' ;
@@ -136,6 +138,7 @@ export class GraphQLSchema {
136138 __validationErrors : ?$ReadOnlyArray < GraphQLError > ;
137139 // Referenced by execute()
138140 __experimentalDeferFragmentSpreads : boolean ;
141+ __experimentalStream : boolean ;
139142
140143 constructor ( config : $ReadOnly < GraphQLSchemaConfig > ) : void {
141144 // If this schema was built from a source known to be valid, then it may be
@@ -163,14 +166,27 @@ export class GraphQLSchema {
163166 this . astNode = config . astNode ;
164167 this . extensionASTNodes = config . extensionASTNodes ;
165168
166- this . __experimentalDeferFragmentSpreads =
167- config . experimentalDeferFragmentSpreads || false ;
169+ this . __experimentalStream = config . experimentalStream || false ;
168170 this . _queryType = config . query ;
169171 this . _mutationType = config . mutation ;
170172 this . _subscriptionType = config . subscription ;
171173 // Provide specified directives (e.g. @include and @skip) by default.
172174 this . _directives = config . directives || specifiedDirectives ;
173175
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+
174190 // Build type map now to detect any errors within this schema.
175191 const initialTypes : Array < ?GraphQLNamedType > = [
176192 this . _queryType ,
@@ -320,6 +336,18 @@ export type GraphQLSchemaValidationOptions = {|
320336 * Default: false
321337 */
322338 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 ,
323351| } ;
324352
325353export type GraphQLSchemaConfig = { |
0 commit comments