@@ -59,6 +59,7 @@ interface CollectFieldsContext {
59
59
visitedFragmentNames : Set < string > ;
60
60
hideSuggestions : boolean ;
61
61
forbiddenDirectiveInstances : Array < DirectiveNode > ;
62
+ forbidSkipAndInclude : boolean ;
62
63
}
63
64
64
65
/**
@@ -78,7 +79,7 @@ export function collectFields(
78
79
runtimeType : GraphQLObjectType ,
79
80
selectionSet : SelectionSetNode ,
80
81
hideSuggestions : boolean ,
81
- forbidSkipInclude = false ,
82
+ forbidSkipAndInclude = false ,
82
83
) : {
83
84
groupedFieldSet : GroupedFieldSet ;
84
85
newDeferUsages : ReadonlyArray < DeferUsage > ;
@@ -94,17 +95,10 @@ export function collectFields(
94
95
visitedFragmentNames : new Set ( ) ,
95
96
hideSuggestions,
96
97
forbiddenDirectiveInstances : [ ] ,
98
+ forbidSkipAndInclude,
97
99
} ;
98
100
99
- collectFieldsImpl (
100
- context ,
101
- selectionSet ,
102
- groupedFieldSet ,
103
- newDeferUsages ,
104
- undefined ,
105
- undefined ,
106
- forbidSkipInclude ,
107
- ) ;
101
+ collectFieldsImpl ( context , selectionSet , groupedFieldSet , newDeferUsages ) ;
108
102
return {
109
103
groupedFieldSet,
110
104
newDeferUsages,
@@ -177,7 +171,6 @@ function collectFieldsImpl(
177
171
newDeferUsages : Array < DeferUsage > ,
178
172
deferUsage ?: DeferUsage ,
179
173
fragmentVariableValues ?: VariableValues ,
180
- forbidSkipInclude = false ,
181
174
) : void {
182
175
const {
183
176
schema,
@@ -198,7 +191,6 @@ function collectFieldsImpl(
198
191
variableValues ,
199
192
fragmentVariableValues ,
200
193
hideSuggestions ,
201
- forbidSkipInclude ,
202
194
)
203
195
) {
204
196
continue ;
@@ -218,7 +210,6 @@ function collectFieldsImpl(
218
210
variableValues ,
219
211
fragmentVariableValues ,
220
212
hideSuggestions ,
221
- forbidSkipInclude ,
222
213
) ||
223
214
! doesFragmentConditionMatch ( schema , selection , runtimeType )
224
215
) {
@@ -266,7 +257,6 @@ function collectFieldsImpl(
266
257
variableValues ,
267
258
fragmentVariableValues ,
268
259
hideSuggestions ,
269
- forbidSkipInclude ,
270
260
)
271
261
) {
272
262
continue ;
@@ -368,12 +358,11 @@ function shouldIncludeNode(
368
358
variableValues : VariableValues ,
369
359
fragmentVariableValues : VariableValues | undefined ,
370
360
hideSuggestions : Maybe < boolean > ,
371
- forbidSkipInclude : boolean ,
372
361
) : boolean {
373
362
const skipDirectiveNode = node . directives ?. find (
374
363
( directive ) => directive . name . value === GraphQLSkipDirective . name ,
375
364
) ;
376
- if ( skipDirectiveNode && forbidSkipInclude ) {
365
+ if ( skipDirectiveNode && context . forbidSkipAndInclude ) {
377
366
context . forbiddenDirectiveInstances . push ( skipDirectiveNode ) ;
378
367
return false ;
379
368
}
@@ -393,7 +382,7 @@ function shouldIncludeNode(
393
382
const includeDirectiveNode = node . directives ?. find (
394
383
( directive ) => directive . name . value === GraphQLIncludeDirective . name ,
395
384
) ;
396
- if ( includeDirectiveNode && forbidSkipInclude ) {
385
+ if ( includeDirectiveNode && context . forbidSkipAndInclude ) {
397
386
context . forbiddenDirectiveInstances . push ( includeDirectiveNode ) ;
398
387
return false ;
399
388
}
0 commit comments