relay-runtime 9.0.0 → 10.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/handlers/RelayDefaultHandlerProvider.js.flow +47 -0
  2. package/handlers/connection/ConnectionHandler.js.flow +549 -0
  3. package/handlers/connection/ConnectionInterface.js.flow +92 -0
  4. package/handlers/connection/MutationHandlers.js.flow +199 -0
  5. package/index.js +1 -1
  6. package/index.js.flow +335 -0
  7. package/lib/handlers/RelayDefaultHandlerProvider.js +20 -0
  8. package/lib/handlers/connection/ConnectionHandler.js +1 -3
  9. package/lib/handlers/connection/MutationHandlers.js +212 -0
  10. package/lib/index.js +14 -2
  11. package/lib/mutations/RelayDeclarativeMutationConfig.js +22 -45
  12. package/lib/mutations/RelayRecordProxy.js +1 -3
  13. package/lib/mutations/RelayRecordSourceMutator.js +1 -3
  14. package/lib/mutations/RelayRecordSourceProxy.js +1 -3
  15. package/lib/mutations/RelayRecordSourceSelectorProxy.js +1 -3
  16. package/lib/mutations/commitMutation.js +2 -3
  17. package/lib/mutations/validateMutation.js +40 -9
  18. package/lib/network/RelayObservable.js +9 -9
  19. package/lib/network/RelayQueryResponseCache.js +8 -6
  20. package/lib/query/GraphQLTag.js +2 -1
  21. package/lib/query/PreloadableQueryRegistry.js +70 -0
  22. package/lib/query/fetchQuery.js +2 -3
  23. package/lib/query/fetchQueryInternal.js +5 -14
  24. package/lib/store/DataChecker.js +200 -71
  25. package/lib/store/RelayConcreteVariables.js +6 -2
  26. package/lib/store/RelayModernEnvironment.js +124 -65
  27. package/lib/store/RelayModernFragmentSpecResolver.js +19 -14
  28. package/lib/store/RelayModernOperationDescriptor.js +6 -5
  29. package/lib/store/RelayModernQueryExecutor.js +122 -73
  30. package/lib/store/RelayModernRecord.js +14 -9
  31. package/lib/store/RelayModernSelector.js +6 -2
  32. package/lib/store/RelayModernStore.js +281 -131
  33. package/lib/store/RelayOperationTracker.js +35 -78
  34. package/lib/store/RelayOptimisticRecordSource.js +7 -5
  35. package/lib/store/RelayPublishQueue.js +2 -4
  36. package/lib/store/RelayReader.js +304 -52
  37. package/lib/store/RelayRecordSource.js +1 -3
  38. package/lib/store/RelayRecordSourceMapImpl.js +13 -18
  39. package/lib/store/RelayReferenceMarker.js +125 -14
  40. package/lib/store/RelayResponseNormalizer.js +261 -66
  41. package/lib/store/RelayStoreReactFlightUtils.js +47 -0
  42. package/lib/store/RelayStoreUtils.js +1 -0
  43. package/lib/store/StoreInspector.js +8 -8
  44. package/lib/store/TypeID.js +28 -0
  45. package/lib/store/cloneRelayScalarHandleSourceField.js +44 -0
  46. package/lib/store/defaultRequiredFieldLogger.js +18 -0
  47. package/lib/store/normalizeRelayPayload.js +6 -2
  48. package/lib/store/readInlineData.js +1 -1
  49. package/lib/subscription/requestSubscription.js +4 -3
  50. package/lib/util/NormalizationNode.js +1 -5
  51. package/lib/util/RelayConcreteNode.js +11 -6
  52. package/lib/util/RelayError.js +39 -9
  53. package/lib/util/RelayFeatureFlags.js +6 -3
  54. package/lib/util/RelayReplaySubject.js +3 -3
  55. package/lib/util/createPayloadFor3DField.js +7 -2
  56. package/lib/util/getFragmentIdentifier.js +12 -3
  57. package/lib/util/getOperation.js +33 -0
  58. package/lib/util/getRequestIdentifier.js +2 -2
  59. package/lib/util/isEmptyObject.js +25 -0
  60. package/lib/util/recycleNodesInto.js +6 -7
  61. package/lib/util/reportMissingRequiredFields.js +48 -0
  62. package/mutations/RelayDeclarativeMutationConfig.js.flow +380 -0
  63. package/mutations/RelayRecordProxy.js.flow +165 -0
  64. package/mutations/RelayRecordSourceMutator.js.flow +238 -0
  65. package/mutations/RelayRecordSourceProxy.js.flow +164 -0
  66. package/mutations/RelayRecordSourceSelectorProxy.js.flow +119 -0
  67. package/mutations/applyOptimisticMutation.js.flow +76 -0
  68. package/mutations/commitLocalUpdate.js.flow +24 -0
  69. package/mutations/commitMutation.js.flow +181 -0
  70. package/mutations/validateMutation.js.flow +242 -0
  71. package/network/ConvertToExecuteFunction.js.flow +49 -0
  72. package/network/RelayNetwork.js.flow +84 -0
  73. package/network/RelayNetworkTypes.js.flow +145 -0
  74. package/network/RelayObservable.js.flow +634 -0
  75. package/network/RelayQueryResponseCache.js.flow +111 -0
  76. package/package.json +2 -2
  77. package/query/GraphQLTag.js.flow +168 -0
  78. package/query/PreloadableQueryRegistry.js.flow +65 -0
  79. package/query/fetchQuery.js.flow +47 -0
  80. package/query/fetchQueryInternal.js.flow +343 -0
  81. package/relay-runtime.js +2 -2
  82. package/relay-runtime.min.js +2 -2
  83. package/store/ClientID.js.flow +43 -0
  84. package/store/DataChecker.js.flow +568 -0
  85. package/store/RelayConcreteVariables.js.flow +96 -0
  86. package/store/RelayModernEnvironment.js.flow +571 -0
  87. package/store/RelayModernFragmentSpecResolver.js.flow +438 -0
  88. package/store/RelayModernOperationDescriptor.js.flow +92 -0
  89. package/store/RelayModernQueryExecutor.js.flow +1345 -0
  90. package/store/RelayModernRecord.js.flow +403 -0
  91. package/store/RelayModernSelector.js.flow +455 -0
  92. package/store/RelayModernStore.js.flow +858 -0
  93. package/store/RelayOperationTracker.js.flow +164 -0
  94. package/store/RelayOptimisticRecordSource.js.flow +119 -0
  95. package/store/RelayPublishQueue.js.flow +401 -0
  96. package/store/RelayReader.js.flow +638 -0
  97. package/store/RelayRecordSource.js.flow +29 -0
  98. package/store/RelayRecordSourceMapImpl.js.flow +87 -0
  99. package/store/RelayRecordState.js.flow +37 -0
  100. package/store/RelayReferenceMarker.js.flow +324 -0
  101. package/store/RelayResponseNormalizer.js.flow +791 -0
  102. package/store/RelayStoreReactFlightUtils.js.flow +64 -0
  103. package/store/RelayStoreTypes.js.flow +958 -0
  104. package/store/RelayStoreUtils.js.flow +219 -0
  105. package/store/StoreInspector.js.flow +171 -0
  106. package/store/TypeID.js.flow +28 -0
  107. package/store/ViewerPattern.js.flow +26 -0
  108. package/store/cloneRelayHandleSourceField.js.flow +66 -0
  109. package/store/cloneRelayScalarHandleSourceField.js.flow +62 -0
  110. package/store/createFragmentSpecResolver.js.flow +55 -0
  111. package/store/createRelayContext.js.flow +44 -0
  112. package/store/defaultGetDataID.js.flow +27 -0
  113. package/store/defaultRequiredFieldLogger.js.flow +23 -0
  114. package/store/hasOverlappingIDs.js.flow +34 -0
  115. package/store/isRelayModernEnvironment.js.flow +27 -0
  116. package/store/normalizeRelayPayload.js.flow +51 -0
  117. package/store/readInlineData.js.flow +75 -0
  118. package/subscription/requestSubscription.js.flow +103 -0
  119. package/util/JSResourceTypes.flow.js.flow +20 -0
  120. package/util/NormalizationNode.js.flow +213 -0
  121. package/util/ReaderNode.js.flow +227 -0
  122. package/util/RelayConcreteNode.js.flow +99 -0
  123. package/util/RelayDefaultHandleKey.js.flow +17 -0
  124. package/util/RelayError.js.flow +62 -0
  125. package/util/RelayFeatureFlags.js.flow +37 -0
  126. package/util/RelayProfiler.js.flow +284 -0
  127. package/util/RelayReplaySubject.js.flow +135 -0
  128. package/util/RelayRuntimeTypes.js.flow +72 -0
  129. package/util/createPayloadFor3DField.js.flow +43 -0
  130. package/util/deepFreeze.js.flow +36 -0
  131. package/util/generateID.js.flow +21 -0
  132. package/util/getFragmentIdentifier.js.flow +76 -0
  133. package/util/getOperation.js.flow +40 -0
  134. package/util/getRelayHandleKey.js.flow +41 -0
  135. package/util/getRequestIdentifier.js.flow +42 -0
  136. package/util/isEmptyObject.js.flow +25 -0
  137. package/util/isPromise.js.flow +21 -0
  138. package/util/isScalarAndEqual.js.flow +26 -0
  139. package/util/recycleNodesInto.js.flow +87 -0
  140. package/util/reportMissingRequiredFields.js.flow +51 -0
  141. package/util/resolveImmediate.js.flow +30 -0
  142. package/util/stableCopy.js.flow +35 -0
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ // flowlint ambiguous-object-type:error
12
+
13
+ 'use strict';
14
+
15
+ const RelayRecordState = require('./RelayRecordState');
16
+
17
+ import type {DataID} from '../util/RelayRuntimeTypes';
18
+ import type {RecordState} from './RelayRecordState';
19
+ import type {MutableRecordSource, Record, RecordMap} from './RelayStoreTypes';
20
+
21
+ const {EXISTENT, NONEXISTENT, UNKNOWN} = RelayRecordState;
22
+
23
+ /**
24
+ * An implementation of the `MutableRecordSource` interface (defined in
25
+ * `RelayStoreTypes`) that holds all records in memory (JS Map).
26
+ */
27
+ class RelayMapRecordSourceMapImpl implements MutableRecordSource {
28
+ _records: Map<DataID, ?Record>;
29
+
30
+ constructor(records?: RecordMap) {
31
+ this._records = new Map();
32
+ if (records != null) {
33
+ Object.keys(records).forEach(key => {
34
+ this._records.set(key, records[key]);
35
+ });
36
+ }
37
+ }
38
+
39
+ clear(): void {
40
+ this._records = new Map();
41
+ }
42
+
43
+ delete(dataID: DataID): void {
44
+ this._records.set(dataID, null);
45
+ }
46
+
47
+ get(dataID: DataID): ?Record {
48
+ return this._records.get(dataID);
49
+ }
50
+
51
+ getRecordIDs(): Array<DataID> {
52
+ return Array.from(this._records.keys());
53
+ }
54
+
55
+ getStatus(dataID: DataID): RecordState {
56
+ if (!this._records.has(dataID)) {
57
+ return UNKNOWN;
58
+ }
59
+ return this._records.get(dataID) == null ? NONEXISTENT : EXISTENT;
60
+ }
61
+
62
+ has(dataID: DataID): boolean {
63
+ return this._records.has(dataID);
64
+ }
65
+
66
+ remove(dataID: DataID): void {
67
+ this._records.delete(dataID);
68
+ }
69
+
70
+ set(dataID: DataID, record: Record): void {
71
+ this._records.set(dataID, record);
72
+ }
73
+
74
+ size(): number {
75
+ return this._records.size;
76
+ }
77
+
78
+ toJSON(): {[DataID]: ?Record, ...} {
79
+ const obj = {};
80
+ for (const [key, value] of this._records) {
81
+ obj[key] = value;
82
+ }
83
+ return obj;
84
+ }
85
+ }
86
+
87
+ module.exports = RelayMapRecordSourceMapImpl;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ * @format
9
+ */
10
+
11
+ // flowlint ambiguous-object-type:error
12
+
13
+ 'use strict';
14
+
15
+ export type RecordState = $Keys<typeof RelayRecordState>;
16
+
17
+ const RelayRecordState = {
18
+ /**
19
+ * Record exists (either fetched from the server or produced by a local,
20
+ * optimistic update).
21
+ */
22
+ EXISTENT: 'EXISTENT',
23
+
24
+ /**
25
+ * Record is known not to exist (either as the result of a mutation, or
26
+ * because the server returned `null` when queried for the record).
27
+ */
28
+ NONEXISTENT: 'NONEXISTENT',
29
+
30
+ /**
31
+ * Record State is unknown because it has not yet been fetched from the
32
+ * server.
33
+ */
34
+ UNKNOWN: 'UNKNOWN',
35
+ };
36
+
37
+ module.exports = RelayRecordState;
@@ -0,0 +1,324 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ // flowlint ambiguous-object-type:error
12
+
13
+ 'use strict';
14
+
15
+ const RelayConcreteNode = require('../util/RelayConcreteNode');
16
+ const RelayFeatureFlags = require('../util/RelayFeatureFlags');
17
+ const RelayModernRecord = require('./RelayModernRecord');
18
+ const RelayStoreReactFlightUtils = require('./RelayStoreReactFlightUtils');
19
+ const RelayStoreUtils = require('./RelayStoreUtils');
20
+
21
+ const cloneRelayHandleSourceField = require('./cloneRelayHandleSourceField');
22
+ const getOperation = require('../util/getOperation');
23
+ const invariant = require('invariant');
24
+
25
+ const {generateTypeID} = require('./TypeID');
26
+
27
+ import type {ReactFlightPayloadQuery} from '../network/RelayNetworkTypes';
28
+ import type {
29
+ NormalizationFlightField,
30
+ NormalizationLinkedField,
31
+ NormalizationModuleImport,
32
+ NormalizationNode,
33
+ NormalizationSelection,
34
+ } from '../util/NormalizationNode';
35
+ import type {DataID, Variables} from '../util/RelayRuntimeTypes';
36
+ import type {
37
+ NormalizationSelector,
38
+ OperationLoader,
39
+ Record,
40
+ RecordSource,
41
+ } from './RelayStoreTypes';
42
+
43
+ const {
44
+ CONDITION,
45
+ CLIENT_EXTENSION,
46
+ DEFER,
47
+ FLIGHT_FIELD,
48
+ FRAGMENT_SPREAD,
49
+ INLINE_FRAGMENT,
50
+ LINKED_FIELD,
51
+ MODULE_IMPORT,
52
+ LINKED_HANDLE,
53
+ SCALAR_FIELD,
54
+ SCALAR_HANDLE,
55
+ STREAM,
56
+ TYPE_DISCRIMINATOR,
57
+ } = RelayConcreteNode;
58
+ const {ROOT_ID, getStorageKey, getModuleOperationKey} = RelayStoreUtils;
59
+
60
+ function mark(
61
+ recordSource: RecordSource,
62
+ selector: NormalizationSelector,
63
+ references: Set<DataID>,
64
+ operationLoader: ?OperationLoader,
65
+ ): void {
66
+ const {dataID, node, variables} = selector;
67
+ const marker = new RelayReferenceMarker(
68
+ recordSource,
69
+ variables,
70
+ references,
71
+ operationLoader,
72
+ );
73
+ marker.mark(node, dataID);
74
+ }
75
+
76
+ /**
77
+ * @private
78
+ */
79
+ class RelayReferenceMarker {
80
+ _operationLoader: OperationLoader | null;
81
+ _operationName: ?string;
82
+ _recordSource: RecordSource;
83
+ _references: Set<DataID>;
84
+ _variables: Variables;
85
+
86
+ constructor(
87
+ recordSource: RecordSource,
88
+ variables: Variables,
89
+ references: Set<DataID>,
90
+ operationLoader: ?OperationLoader,
91
+ ) {
92
+ this._operationLoader = operationLoader ?? null;
93
+ this._operationName = null;
94
+ this._recordSource = recordSource;
95
+ this._references = references;
96
+ this._variables = variables;
97
+ }
98
+
99
+ mark(node: NormalizationNode, dataID: DataID): void {
100
+ if (node.kind === 'Operation' || node.kind === 'SplitOperation') {
101
+ this._operationName = node.name;
102
+ }
103
+ this._traverse(node, dataID);
104
+ }
105
+
106
+ _traverse(node: NormalizationNode, dataID: DataID): void {
107
+ this._references.add(dataID);
108
+ const record = this._recordSource.get(dataID);
109
+ if (record == null) {
110
+ return;
111
+ }
112
+ this._traverseSelections(node.selections, record);
113
+ }
114
+
115
+ _getVariableValue(name: string): mixed {
116
+ invariant(
117
+ this._variables.hasOwnProperty(name),
118
+ 'RelayReferenceMarker(): Undefined variable `%s`.',
119
+ name,
120
+ );
121
+ return this._variables[name];
122
+ }
123
+
124
+ _traverseSelections(
125
+ selections: $ReadOnlyArray<NormalizationSelection>,
126
+ record: Record,
127
+ ): void {
128
+ selections.forEach(selection => {
129
+ /* eslint-disable no-fallthrough */
130
+ switch (selection.kind) {
131
+ case LINKED_FIELD:
132
+ if (selection.plural) {
133
+ this._traversePluralLink(selection, record);
134
+ } else {
135
+ this._traverseLink(selection, record);
136
+ }
137
+ break;
138
+ case CONDITION:
139
+ const conditionValue = this._getVariableValue(selection.condition);
140
+ if (conditionValue === selection.passingValue) {
141
+ this._traverseSelections(selection.selections, record);
142
+ }
143
+ break;
144
+ case INLINE_FRAGMENT:
145
+ if (selection.abstractKey == null) {
146
+ const typeName = RelayModernRecord.getType(record);
147
+ if (typeName != null && typeName === selection.type) {
148
+ this._traverseSelections(selection.selections, record);
149
+ }
150
+ } else if (RelayFeatureFlags.ENABLE_PRECISE_TYPE_REFINEMENT) {
151
+ const typeName = RelayModernRecord.getType(record);
152
+ const typeID = generateTypeID(typeName);
153
+ this._references.add(typeID);
154
+ this._traverseSelections(selection.selections, record);
155
+ } else {
156
+ this._traverseSelections(selection.selections, record);
157
+ }
158
+ break;
159
+ // $FlowFixMe[incompatible-type]
160
+ case FRAGMENT_SPREAD:
161
+ invariant(
162
+ false,
163
+ 'RelayReferenceMarker(): Unexpected fragment spread `...%s`, ' +
164
+ 'expected all fragments to be inlined.',
165
+ selection.name,
166
+ );
167
+ case LINKED_HANDLE:
168
+ // The selections for a "handle" field are the same as those of the
169
+ // original linked field where the handle was applied. Reference marking
170
+ // therefore requires traversing the original field selections against
171
+ // the synthesized client field.
172
+ //
173
+ // TODO: Instead of finding the source field in `selections`, change
174
+ // the concrete structure to allow shared subtrees, and have the linked
175
+ // handle directly refer to the same selections as the LinkedField that
176
+ // it was split from.
177
+ const handleField = cloneRelayHandleSourceField(
178
+ selection,
179
+ selections,
180
+ this._variables,
181
+ );
182
+ if (handleField.plural) {
183
+ this._traversePluralLink(handleField, record);
184
+ } else {
185
+ this._traverseLink(handleField, record);
186
+ }
187
+ break;
188
+ case DEFER:
189
+ case STREAM:
190
+ this._traverseSelections(selection.selections, record);
191
+ break;
192
+ case SCALAR_FIELD:
193
+ case SCALAR_HANDLE:
194
+ break;
195
+ case TYPE_DISCRIMINATOR: {
196
+ if (RelayFeatureFlags.ENABLE_PRECISE_TYPE_REFINEMENT) {
197
+ const typeName = RelayModernRecord.getType(record);
198
+ const typeID = generateTypeID(typeName);
199
+ this._references.add(typeID);
200
+ }
201
+ break;
202
+ }
203
+ case MODULE_IMPORT:
204
+ this._traverseModuleImport(selection, record);
205
+ break;
206
+ case CLIENT_EXTENSION:
207
+ this._traverseSelections(selection.selections, record);
208
+ break;
209
+ case FLIGHT_FIELD:
210
+ if (RelayFeatureFlags.ENABLE_REACT_FLIGHT_COMPONENT_FIELD) {
211
+ this._traverseFlightField(selection, record);
212
+ } else {
213
+ throw new Error('Flight fields are not yet supported.');
214
+ }
215
+ break;
216
+ default:
217
+ (selection: empty);
218
+ invariant(
219
+ false,
220
+ 'RelayReferenceMarker: Unknown AST node `%s`.',
221
+ selection,
222
+ );
223
+ }
224
+ });
225
+ }
226
+
227
+ _traverseModuleImport(
228
+ moduleImport: NormalizationModuleImport,
229
+ record: Record,
230
+ ): void {
231
+ const operationLoader = this._operationLoader;
232
+ invariant(
233
+ operationLoader !== null,
234
+ 'RelayReferenceMarker: Expected an operationLoader to be configured when using `@module`. ' +
235
+ 'Could not load fragment `%s` in operation `%s`.',
236
+ moduleImport.fragmentName,
237
+ this._operationName ?? '(unknown)',
238
+ );
239
+ const operationKey = getModuleOperationKey(moduleImport.documentName);
240
+ const operationReference = RelayModernRecord.getValue(record, operationKey);
241
+ if (operationReference == null) {
242
+ return;
243
+ }
244
+ const normalizationRootNode = operationLoader.get(operationReference);
245
+ if (normalizationRootNode != null) {
246
+ const selections = getOperation(normalizationRootNode).selections;
247
+ this._traverseSelections(selections, record);
248
+ }
249
+ // Otherwise, if the operation is not available, we assume that the data
250
+ // cannot have been processed yet and therefore isn't in the store to
251
+ // begin with.
252
+ }
253
+
254
+ _traverseLink(field: NormalizationLinkedField, record: Record): void {
255
+ const storageKey = getStorageKey(field, this._variables);
256
+ const linkedID = RelayModernRecord.getLinkedRecordID(record, storageKey);
257
+
258
+ if (linkedID == null) {
259
+ return;
260
+ }
261
+ this._traverse(field, linkedID);
262
+ }
263
+
264
+ _traversePluralLink(field: NormalizationLinkedField, record: Record): void {
265
+ const storageKey = getStorageKey(field, this._variables);
266
+ const linkedIDs = RelayModernRecord.getLinkedRecordIDs(record, storageKey);
267
+
268
+ if (linkedIDs == null) {
269
+ return;
270
+ }
271
+ linkedIDs.forEach(linkedID => {
272
+ if (linkedID != null) {
273
+ this._traverse(field, linkedID);
274
+ }
275
+ });
276
+ }
277
+
278
+ _traverseFlightField(field: NormalizationFlightField, record: Record): void {
279
+ const storageKey = getStorageKey(field, this._variables);
280
+ const linkedID = RelayModernRecord.getLinkedRecordID(record, storageKey);
281
+ if (linkedID == null) {
282
+ return;
283
+ }
284
+ this._references.add(linkedID);
285
+
286
+ const reactFlightClientResponseRecord = this._recordSource.get(linkedID);
287
+
288
+ if (reactFlightClientResponseRecord == null) {
289
+ return;
290
+ }
291
+
292
+ const reachableQueries = RelayModernRecord.getValue(
293
+ reactFlightClientResponseRecord,
294
+ RelayStoreReactFlightUtils.REACT_FLIGHT_QUERIES_STORAGE_KEY,
295
+ );
296
+
297
+ if (!Array.isArray(reachableQueries)) {
298
+ return;
299
+ }
300
+
301
+ const operationLoader = this._operationLoader;
302
+ invariant(
303
+ operationLoader !== null,
304
+ 'DataChecker: Expected an operationLoader to be configured when using ' +
305
+ 'React Flight',
306
+ );
307
+ // In Flight, the variables that are in scope for reachable queries aren't
308
+ // the same as what's in scope for the outer query.
309
+ const prevVariables = this._variables;
310
+ // $FlowFixMe[incompatible-cast]
311
+ for (const query of (reachableQueries: Array<ReactFlightPayloadQuery>)) {
312
+ this._variables = query.variables;
313
+ const operationReference = query.module;
314
+ const normalizationRootNode = operationLoader.get(operationReference);
315
+ if (normalizationRootNode != null) {
316
+ const operation = getOperation(normalizationRootNode);
317
+ this._traverse(operation, ROOT_ID);
318
+ }
319
+ }
320
+ this._variables = prevVariables;
321
+ }
322
+ }
323
+
324
+ module.exports = {mark};