@@ -35,7 +35,7 @@ export interface DeferUsage {
35
35
export interface FieldDetails {
36
36
node : FieldNode ;
37
37
deferUsage ?: DeferUsage | undefined ;
38
- fragmentVariableValues ?: { [ variable : string ] : unknown } | undefined ;
38
+ scopedVariableValues ?: { [ variable : string ] : unknown } | undefined ;
39
39
}
40
40
41
41
export type FieldGroup = ReadonlyArray < FieldDetails > ;
@@ -131,14 +131,14 @@ export function collectSubfields(
131
131
for ( const fieldDetail of fieldGroup ) {
132
132
const selectionSet = fieldDetail . node . selectionSet ;
133
133
if ( selectionSet ) {
134
- const { deferUsage, fragmentVariableValues } = fieldDetail ;
134
+ const { deferUsage, scopedVariableValues } = fieldDetail ;
135
135
collectFieldsImpl (
136
136
context ,
137
137
selectionSet ,
138
138
subGroupedFieldSet ,
139
139
newDeferUsages ,
140
140
deferUsage ,
141
- fragmentVariableValues ,
141
+ scopedVariableValues ,
142
142
) ;
143
143
}
144
144
}
@@ -156,43 +156,43 @@ function collectFieldsImpl(
156
156
groupedFieldSet : AccumulatorMap < string , FieldDetails > ,
157
157
newDeferUsages : Array < DeferUsage > ,
158
158
deferUsage ?: DeferUsage ,
159
- fragmentVariableValues ?: { [ variable : string ] : unknown } ,
159
+ scopedVariableValues ?: { [ variable : string ] : unknown } ,
160
160
) : void {
161
161
const {
162
162
schema,
163
163
fragments,
164
- variableValues,
164
+ variableValues : operationVariableValues ,
165
165
runtimeType,
166
166
operation,
167
167
visitedFragmentNames,
168
168
} = context ;
169
169
170
- const scopedVariableValues = fragmentVariableValues ?? variableValues ;
170
+ const variableValues = scopedVariableValues ?? operationVariableValues ;
171
171
172
172
for ( const selection of selectionSet . selections ) {
173
173
switch ( selection . kind ) {
174
174
case Kind . FIELD : {
175
- if ( ! shouldIncludeNode ( scopedVariableValues , selection ) ) {
175
+ if ( ! shouldIncludeNode ( variableValues , selection ) ) {
176
176
continue ;
177
177
}
178
178
groupedFieldSet . add ( getFieldEntryKey ( selection ) , {
179
179
node : selection ,
180
180
deferUsage,
181
- fragmentVariableValues ,
181
+ scopedVariableValues ,
182
182
} ) ;
183
183
break ;
184
184
}
185
185
case Kind . INLINE_FRAGMENT : {
186
186
if (
187
- ! shouldIncludeNode ( scopedVariableValues , selection ) ||
187
+ ! shouldIncludeNode ( variableValues , selection ) ||
188
188
! doesFragmentConditionMatch ( schema , selection , runtimeType )
189
189
) {
190
190
continue ;
191
191
}
192
192
193
193
const newDeferUsage = getDeferUsage (
194
194
operation ,
195
- scopedVariableValues ,
195
+ variableValues ,
196
196
selection ,
197
197
deferUsage ,
198
198
) ;
@@ -204,7 +204,7 @@ function collectFieldsImpl(
204
204
groupedFieldSet ,
205
205
newDeferUsages ,
206
206
deferUsage ,
207
- fragmentVariableValues ,
207
+ scopedVariableValues ,
208
208
) ;
209
209
} else {
210
210
newDeferUsages . push ( newDeferUsage ) ;
@@ -214,7 +214,7 @@ function collectFieldsImpl(
214
214
groupedFieldSet ,
215
215
newDeferUsages ,
216
216
newDeferUsage ,
217
- fragmentVariableValues ,
217
+ scopedVariableValues ,
218
218
) ;
219
219
}
220
220
@@ -225,15 +225,15 @@ function collectFieldsImpl(
225
225
226
226
const newDeferUsage = getDeferUsage (
227
227
operation ,
228
- scopedVariableValues ,
228
+ variableValues ,
229
229
selection ,
230
230
deferUsage ,
231
231
) ;
232
232
233
233
if (
234
234
! newDeferUsage &&
235
235
( visitedFragmentNames . has ( fragName ) ||
236
- ! shouldIncludeNode ( scopedVariableValues , selection ) )
236
+ ! shouldIncludeNode ( variableValues , selection ) )
237
237
) {
238
238
continue ;
239
239
}
@@ -247,18 +247,20 @@ function collectFieldsImpl(
247
247
}
248
248
249
249
const fragmentVariableSignatures = fragment . variableSignatures ;
250
- let newFragmentVariableValues :
250
+ let newScopedVariableValues :
251
251
| { [ variable : string ] : unknown }
252
252
| undefined ;
253
253
if ( fragmentVariableSignatures ) {
254
- newFragmentVariableValues = experimentalGetArgumentValues (
254
+ newScopedVariableValues = experimentalGetArgumentValues (
255
255
selection ,
256
256
Object . values ( fragmentVariableSignatures ) ,
257
- scopedVariableValues ,
257
+ variableValues ,
258
258
) ;
259
- for ( const [ variableName , value ] of Object . entries ( variableValues ) ) {
259
+ for ( const [ variableName , value ] of Object . entries (
260
+ operationVariableValues ,
261
+ ) ) {
260
262
if ( ! fragment . variableSignatures ?. [ variableName ] ) {
261
- newFragmentVariableValues [ variableName ] = value ;
263
+ newScopedVariableValues [ variableName ] = value ;
262
264
}
263
265
}
264
266
}
@@ -271,7 +273,7 @@ function collectFieldsImpl(
271
273
groupedFieldSet ,
272
274
newDeferUsages ,
273
275
deferUsage ,
274
- newFragmentVariableValues ,
276
+ newScopedVariableValues ,
275
277
) ;
276
278
} else {
277
279
newDeferUsages . push ( newDeferUsage ) ;
@@ -281,7 +283,7 @@ function collectFieldsImpl(
281
283
groupedFieldSet ,
282
284
newDeferUsages ,
283
285
newDeferUsage ,
284
- newFragmentVariableValues ,
286
+ newScopedVariableValues ,
285
287
) ;
286
288
}
287
289
break ;
0 commit comments