@@ -59,6 +59,7 @@ interface CollectFieldsContext {
5959 visitedFragmentNames : Set < string > ;
6060 hideSuggestions : boolean ;
6161 forbiddenDirectiveInstances : Array < DirectiveNode > ;
62+ forbidSkipAndInclude : boolean ;
6263}
6364
6465/**
@@ -78,7 +79,7 @@ export function collectFields(
7879 runtimeType : GraphQLObjectType ,
7980 selectionSet : SelectionSetNode ,
8081 hideSuggestions : boolean ,
81- forbidSkipInclude = false ,
82+ forbidSkipAndInclude = false ,
8283) : {
8384 groupedFieldSet : GroupedFieldSet ;
8485 newDeferUsages : ReadonlyArray < DeferUsage > ;
@@ -94,17 +95,10 @@ export function collectFields(
9495 visitedFragmentNames : new Set ( ) ,
9596 hideSuggestions,
9697 forbiddenDirectiveInstances : [ ] ,
98+ forbidSkipAndInclude,
9799 } ;
98100
99- collectFieldsImpl (
100- context ,
101- selectionSet ,
102- groupedFieldSet ,
103- newDeferUsages ,
104- undefined ,
105- undefined ,
106- forbidSkipInclude ,
107- ) ;
101+ collectFieldsImpl ( context , selectionSet , groupedFieldSet , newDeferUsages ) ;
108102 return {
109103 groupedFieldSet,
110104 newDeferUsages,
@@ -143,6 +137,7 @@ export function collectSubfields(
143137 visitedFragmentNames : new Set ( ) ,
144138 hideSuggestions,
145139 forbiddenDirectiveInstances : [ ] ,
140+ forbidSkipAndInclude : false ,
146141 } ;
147142 const subGroupedFieldSet = new AccumulatorMap < string , FieldDetails > ( ) ;
148143 const newDeferUsages : Array < DeferUsage > = [ ] ;
@@ -177,7 +172,6 @@ function collectFieldsImpl(
177172 newDeferUsages : Array < DeferUsage > ,
178173 deferUsage ?: DeferUsage ,
179174 fragmentVariableValues ?: VariableValues ,
180- forbidSkipInclude = false ,
181175) : void {
182176 const {
183177 schema,
@@ -198,7 +192,6 @@ function collectFieldsImpl(
198192 variableValues ,
199193 fragmentVariableValues ,
200194 hideSuggestions ,
201- forbidSkipInclude ,
202195 )
203196 ) {
204197 continue ;
@@ -218,7 +211,6 @@ function collectFieldsImpl(
218211 variableValues ,
219212 fragmentVariableValues ,
220213 hideSuggestions ,
221- forbidSkipInclude ,
222214 ) ||
223215 ! doesFragmentConditionMatch ( schema , selection , runtimeType )
224216 ) {
@@ -266,7 +258,6 @@ function collectFieldsImpl(
266258 variableValues ,
267259 fragmentVariableValues ,
268260 hideSuggestions ,
269- forbidSkipInclude ,
270261 )
271262 ) {
272263 continue ;
@@ -368,12 +359,11 @@ function shouldIncludeNode(
368359 variableValues : VariableValues ,
369360 fragmentVariableValues : VariableValues | undefined ,
370361 hideSuggestions : Maybe < boolean > ,
371- forbidSkipInclude : boolean ,
372362) : boolean {
373363 const skipDirectiveNode = node . directives ?. find (
374364 ( directive ) => directive . name . value === GraphQLSkipDirective . name ,
375365 ) ;
376- if ( skipDirectiveNode && forbidSkipInclude ) {
366+ if ( skipDirectiveNode && context . forbidSkipAndInclude ) {
377367 context . forbiddenDirectiveInstances . push ( skipDirectiveNode ) ;
378368 return false ;
379369 }
@@ -393,7 +383,7 @@ function shouldIncludeNode(
393383 const includeDirectiveNode = node . directives ?. find (
394384 ( directive ) => directive . name . value === GraphQLIncludeDirective . name ,
395385 ) ;
396- if ( includeDirectiveNode && forbidSkipInclude ) {
386+ if ( includeDirectiveNode && context . forbidSkipAndInclude ) {
397387 context . forbiddenDirectiveInstances . push ( includeDirectiveNode ) ;
398388 return false ;
399389 }
0 commit comments