@@ -25,22 +25,18 @@ import type { GraphQLSchema } from '../type/schema.js';
25
25
import { typeFromAST } from '../utilities/typeFromAST.js' ;
26
26
27
27
import type { GraphQLVariableSignature } from './getVariableSignature.js' ;
28
- import { experimentalGetArgumentValues , getDirectiveValues } from './values.js' ;
28
+ import type { VariableValues } from './values.js' ;
29
+ import { getDirectiveValues , getFragmentVariableValues } from './values.js' ;
29
30
30
31
export interface DeferUsage {
31
32
label : string | undefined ;
32
33
parentDeferUsage : DeferUsage | undefined ;
33
34
}
34
35
35
- export interface FragmentVariables {
36
- signatures : ObjMap < GraphQLVariableSignature > ;
37
- values : ObjMap < unknown > ;
38
- }
39
-
40
36
export interface FieldDetails {
41
37
node : FieldNode ;
42
38
deferUsage ?: DeferUsage | undefined ;
43
- fragmentVariables ?: FragmentVariables | undefined ;
39
+ fragmentVariableValues ?: VariableValues | undefined ;
44
40
}
45
41
46
42
export type FieldGroup = ReadonlyArray < FieldDetails > ;
@@ -55,7 +51,7 @@ export interface FragmentDetails {
55
51
interface CollectFieldsContext {
56
52
schema : GraphQLSchema ;
57
53
fragments : ObjMap < FragmentDetails > ;
58
- variableValues : { [ variable : string ] : unknown } ;
54
+ variableValues : VariableValues ;
59
55
operation : OperationDefinitionNode ;
60
56
runtimeType : GraphQLObjectType ;
61
57
visitedFragmentNames : Set < string > ;
@@ -73,7 +69,7 @@ interface CollectFieldsContext {
73
69
export function collectFields (
74
70
schema : GraphQLSchema ,
75
71
fragments : ObjMap < FragmentDetails > ,
76
- variableValues : { [ variable : string ] : unknown } ,
72
+ variableValues : VariableValues ,
77
73
runtimeType : GraphQLObjectType ,
78
74
operation : OperationDefinitionNode ,
79
75
) : {
@@ -114,7 +110,7 @@ export function collectFields(
114
110
export function collectSubfields (
115
111
schema : GraphQLSchema ,
116
112
fragments : ObjMap < FragmentDetails > ,
117
- variableValues : { [ variable : string ] : unknown } ,
113
+ variableValues : VariableValues ,
118
114
operation : OperationDefinitionNode ,
119
115
returnType : GraphQLObjectType ,
120
116
fieldGroup : FieldGroup ,
@@ -136,14 +132,14 @@ export function collectSubfields(
136
132
for ( const fieldDetail of fieldGroup ) {
137
133
const selectionSet = fieldDetail . node . selectionSet ;
138
134
if ( selectionSet ) {
139
- const { deferUsage, fragmentVariables } = fieldDetail ;
135
+ const { deferUsage, fragmentVariableValues } = fieldDetail ;
140
136
collectFieldsImpl (
141
137
context ,
142
138
selectionSet ,
143
139
subGroupedFieldSet ,
144
140
newDeferUsages ,
145
141
deferUsage ,
146
- fragmentVariables ,
142
+ fragmentVariableValues ,
147
143
) ;
148
144
}
149
145
}
@@ -161,7 +157,7 @@ function collectFieldsImpl(
161
157
groupedFieldSet : AccumulatorMap < string , FieldDetails > ,
162
158
newDeferUsages : Array < DeferUsage > ,
163
159
deferUsage ?: DeferUsage ,
164
- fragmentVariables ?: FragmentVariables ,
160
+ fragmentVariableValues ?: VariableValues ,
165
161
) : void {
166
162
const {
167
163
schema,
@@ -175,19 +171,25 @@ function collectFieldsImpl(
175
171
for ( const selection of selectionSet . selections ) {
176
172
switch ( selection . kind ) {
177
173
case Kind . FIELD : {
178
- if ( ! shouldIncludeNode ( selection , variableValues , fragmentVariables ) ) {
174
+ if (
175
+ ! shouldIncludeNode ( selection , variableValues , fragmentVariableValues )
176
+ ) {
179
177
continue ;
180
178
}
181
179
groupedFieldSet . add ( getFieldEntryKey ( selection ) , {
182
180
node : selection ,
183
181
deferUsage,
184
- fragmentVariables ,
182
+ fragmentVariableValues ,
185
183
} ) ;
186
184
break ;
187
185
}
188
186
case Kind . INLINE_FRAGMENT : {
189
187
if (
190
- ! shouldIncludeNode ( selection , variableValues , fragmentVariables ) ||
188
+ ! shouldIncludeNode (
189
+ selection ,
190
+ variableValues ,
191
+ fragmentVariableValues ,
192
+ ) ||
191
193
! doesFragmentConditionMatch ( schema , selection , runtimeType )
192
194
) {
193
195
continue ;
@@ -196,7 +198,7 @@ function collectFieldsImpl(
196
198
const newDeferUsage = getDeferUsage (
197
199
operation ,
198
200
variableValues ,
199
- fragmentVariables ,
201
+ fragmentVariableValues ,
200
202
selection ,
201
203
deferUsage ,
202
204
) ;
@@ -208,7 +210,7 @@ function collectFieldsImpl(
208
210
groupedFieldSet ,
209
211
newDeferUsages ,
210
212
deferUsage ,
211
- fragmentVariables ,
213
+ fragmentVariableValues ,
212
214
) ;
213
215
} else {
214
216
newDeferUsages . push ( newDeferUsage ) ;
@@ -218,7 +220,7 @@ function collectFieldsImpl(
218
220
groupedFieldSet ,
219
221
newDeferUsages ,
220
222
newDeferUsage ,
221
- fragmentVariables ,
223
+ fragmentVariableValues ,
222
224
) ;
223
225
}
224
226
@@ -230,15 +232,19 @@ function collectFieldsImpl(
230
232
const newDeferUsage = getDeferUsage (
231
233
operation ,
232
234
variableValues ,
233
- fragmentVariables ,
235
+ fragmentVariableValues ,
234
236
selection ,
235
237
deferUsage ,
236
238
) ;
237
239
238
240
if (
239
241
! newDeferUsage &&
240
242
( visitedFragmentNames . has ( fragName ) ||
241
- ! shouldIncludeNode ( selection , variableValues , fragmentVariables ) )
243
+ ! shouldIncludeNode (
244
+ selection ,
245
+ variableValues ,
246
+ fragmentVariableValues ,
247
+ ) )
242
248
) {
243
249
continue ;
244
250
}
@@ -252,17 +258,14 @@ function collectFieldsImpl(
252
258
}
253
259
254
260
const fragmentVariableSignatures = fragment . variableSignatures ;
255
- let newFragmentVariables : FragmentVariables | undefined ;
261
+ let newFragmentVariableValues : VariableValues | undefined ;
256
262
if ( fragmentVariableSignatures ) {
257
- newFragmentVariables = {
258
- signatures : fragmentVariableSignatures ,
259
- values : experimentalGetArgumentValues (
260
- selection ,
261
- Object . values ( fragmentVariableSignatures ) ,
262
- variableValues ,
263
- fragmentVariables ,
264
- ) ,
265
- } ;
263
+ newFragmentVariableValues = getFragmentVariableValues (
264
+ selection ,
265
+ fragmentVariableSignatures ,
266
+ variableValues ,
267
+ fragmentVariableValues ,
268
+ ) ;
266
269
}
267
270
268
271
if ( ! newDeferUsage ) {
@@ -273,7 +276,7 @@ function collectFieldsImpl(
273
276
groupedFieldSet ,
274
277
newDeferUsages ,
275
278
deferUsage ,
276
- newFragmentVariables ,
279
+ newFragmentVariableValues ,
277
280
) ;
278
281
} else {
279
282
newDeferUsages . push ( newDeferUsage ) ;
@@ -283,7 +286,7 @@ function collectFieldsImpl(
283
286
groupedFieldSet ,
284
287
newDeferUsages ,
285
288
newDeferUsage ,
286
- newFragmentVariables ,
289
+ newFragmentVariableValues ,
287
290
) ;
288
291
}
289
292
break ;
@@ -299,16 +302,16 @@ function collectFieldsImpl(
299
302
*/
300
303
function getDeferUsage (
301
304
operation : OperationDefinitionNode ,
302
- variableValues : { [ variable : string ] : unknown } ,
303
- fragmentVariables : FragmentVariables | undefined ,
305
+ variableValues : VariableValues ,
306
+ fragmentVariableValues : VariableValues | undefined ,
304
307
node : FragmentSpreadNode | InlineFragmentNode ,
305
308
parentDeferUsage : DeferUsage | undefined ,
306
309
) : DeferUsage | undefined {
307
310
const defer = getDirectiveValues (
308
311
GraphQLDeferDirective ,
309
312
node ,
310
313
variableValues ,
311
- fragmentVariables ,
314
+ fragmentVariableValues ,
312
315
) ;
313
316
314
317
if ( ! defer ) {
@@ -336,14 +339,14 @@ function getDeferUsage(
336
339
*/
337
340
function shouldIncludeNode (
338
341
node : FragmentSpreadNode | FieldNode | InlineFragmentNode ,
339
- variableValues : { [ variable : string ] : unknown } ,
340
- fragmentVariables : FragmentVariables | undefined ,
342
+ variableValues : VariableValues ,
343
+ fragmentVariableValues : VariableValues | undefined ,
341
344
) : boolean {
342
345
const skip = getDirectiveValues (
343
346
GraphQLSkipDirective ,
344
347
node ,
345
348
variableValues ,
346
- fragmentVariables ,
349
+ fragmentVariableValues ,
347
350
) ;
348
351
if ( skip ?. if === true ) {
349
352
return false ;
@@ -353,7 +356,7 @@ function shouldIncludeNode(
353
356
GraphQLIncludeDirective ,
354
357
node ,
355
358
variableValues ,
356
- fragmentVariables ,
359
+ fragmentVariableValues ,
357
360
) ;
358
361
if ( include ?. if === false ) {
359
362
return false ;
0 commit comments