react-relay 2.0.0-rc.2 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. package/index.js +2 -2
  2. package/lib/ReactRelayContext.js +6 -3
  3. package/lib/ReactRelayFragmentContainer.js +48 -46
  4. package/lib/ReactRelayFragmentMockRenderer.js +5 -1
  5. package/lib/ReactRelayPaginationContainer.js +102 -68
  6. package/lib/ReactRelayQueryFetcher.js +54 -28
  7. package/lib/ReactRelayQueryRenderer.js +28 -20
  8. package/lib/ReactRelayRefetchContainer.js +70 -58
  9. package/lib/ReactRelayTestMocker.js +56 -43
  10. package/lib/ReactRelayTypes.js +1 -1
  11. package/lib/RelayContext.js +8 -2
  12. package/lib/assertFragmentMap.js +9 -7
  13. package/lib/buildReactRelayContainer.js +32 -23
  14. package/lib/index.js +41 -0
  15. package/lib/isRelayEnvironment.js +1 -1
  16. package/lib/isRelayVariables.js +1 -1
  17. package/lib/readContext.js +7 -4
  18. package/package.json +4 -4
  19. package/react-relay.js +2 -2
  20. package/react-relay.min.js +2 -2
  21. package/classic.js +0 -10
  22. package/compat.js +0 -10
  23. package/lib/ConcreteQuery.js +0 -10
  24. package/lib/GraphQLQueryRunner.js +0 -264
  25. package/lib/GraphQLRange.js +0 -1124
  26. package/lib/GraphQLSegment.js +0 -743
  27. package/lib/GraphQLStoreChangeEmitter.js +0 -141
  28. package/lib/GraphQLStoreQueryResolver.js +0 -288
  29. package/lib/GraphQLStoreRangeUtils.js +0 -126
  30. package/lib/QueryBuilder.js +0 -228
  31. package/lib/ReactRelayClassicExports.js +0 -29
  32. package/lib/ReactRelayCompatContainerBuilder.js +0 -175
  33. package/lib/ReactRelayCompatPublic.js +0 -28
  34. package/lib/ReactRelayContainerProfiler.js +0 -30
  35. package/lib/ReactRelayFragmentContainer-flowtest.js +0 -201
  36. package/lib/ReactRelayPaginationContainer-flowtest.js +0 -213
  37. package/lib/ReactRelayPublic.js +0 -29
  38. package/lib/ReactRelayRefetchContainer-flowtest.js +0 -191
  39. package/lib/RelayCacheProcessor.js +0 -196
  40. package/lib/RelayChangeTracker.js +0 -83
  41. package/lib/RelayClassicContainerUtils.js +0 -49
  42. package/lib/RelayClassicCore.js +0 -34
  43. package/lib/RelayClassicRecordState.js +0 -31
  44. package/lib/RelayCompatContainer.js +0 -25
  45. package/lib/RelayCompatEnvironment.js +0 -27
  46. package/lib/RelayCompatMutations.js +0 -133
  47. package/lib/RelayCompatPaginationContainer.js +0 -27
  48. package/lib/RelayCompatRefetchContainer.js +0 -27
  49. package/lib/RelayCompatTypes.js +0 -10
  50. package/lib/RelayContainer.js +0 -889
  51. package/lib/RelayContainerComparators.js +0 -75
  52. package/lib/RelayContainerProxy.js +0 -21
  53. package/lib/RelayDefaultNetworkLayer.js +0 -192
  54. package/lib/RelayEnvironment.js +0 -449
  55. package/lib/RelayEnvironmentTypes.js +0 -10
  56. package/lib/RelayFetchMode.js +0 -17
  57. package/lib/RelayFragmentPointer.js +0 -161
  58. package/lib/RelayFragmentReference.js +0 -249
  59. package/lib/RelayFragmentSpecResolver.js +0 -305
  60. package/lib/RelayGraphQLMutation.js +0 -288
  61. package/lib/RelayGraphQLTag.js +0 -42
  62. package/lib/RelayInternalTypes.js +0 -15
  63. package/lib/RelayInternals.js +0 -24
  64. package/lib/RelayMetaRoute.js +0 -35
  65. package/lib/RelayMockRenderer.js +0 -71
  66. package/lib/RelayModern-flowtest.js +0 -342
  67. package/lib/RelayModernFlowtest_badref.graphql.js +0 -10
  68. package/lib/RelayModernFlowtest_notref.graphql.js +0 -10
  69. package/lib/RelayModernFlowtest_user.graphql.js +0 -10
  70. package/lib/RelayModernFlowtest_users.graphql.js +0 -10
  71. package/lib/RelayMutation.js +0 -322
  72. package/lib/RelayMutationDebugPrinter.js +0 -47
  73. package/lib/RelayMutationQuery.js +0 -558
  74. package/lib/RelayMutationQueue.js +0 -530
  75. package/lib/RelayMutationRequest.js +0 -103
  76. package/lib/RelayMutationTracker.js +0 -113
  77. package/lib/RelayMutationTransaction.js +0 -92
  78. package/lib/RelayMutationTransactionStatus.js +0 -55
  79. package/lib/RelayNetworkDebug.js +0 -131
  80. package/lib/RelayNetworkLayer.js +0 -185
  81. package/lib/RelayNodeInterface.js +0 -104
  82. package/lib/RelayOperationDescriptor.js +0 -40
  83. package/lib/RelayOptimisticMutationUtils.js +0 -208
  84. package/lib/RelayPendingQueryTracker.js +0 -166
  85. package/lib/RelayPropTypes.js +0 -57
  86. package/lib/RelayPublic.js +0 -44
  87. package/lib/RelayQL.js +0 -128
  88. package/lib/RelayQuery.js +0 -1584
  89. package/lib/RelayQueryCaching.js +0 -33
  90. package/lib/RelayQueryConfig.js +0 -58
  91. package/lib/RelayQueryPath.js +0 -204
  92. package/lib/RelayQueryRequest.js +0 -103
  93. package/lib/RelayQueryTracker.js +0 -86
  94. package/lib/RelayQueryTransform.js +0 -91
  95. package/lib/RelayQueryVisitor.js +0 -93
  96. package/lib/RelayQueryWriter.js +0 -573
  97. package/lib/RelayReadyState.js +0 -83
  98. package/lib/RelayReadyStateRenderer.js +0 -145
  99. package/lib/RelayRecord.js +0 -75
  100. package/lib/RelayRecordStatusMap.js +0 -57
  101. package/lib/RelayRecordStore.js +0 -433
  102. package/lib/RelayRecordWriter.js +0 -601
  103. package/lib/RelayRefQueryDescriptor.js +0 -27
  104. package/lib/RelayRenderer.js +0 -268
  105. package/lib/RelayRootContainer.js +0 -125
  106. package/lib/RelayRoute.js +0 -92
  107. package/lib/RelayRouteFragment.js +0 -44
  108. package/lib/RelaySelector.js +0 -201
  109. package/lib/RelayShallowMock.js +0 -69
  110. package/lib/RelayStaticContainer.js +0 -38
  111. package/lib/RelayStore.js +0 -12
  112. package/lib/RelayStoreConstants.js +0 -20
  113. package/lib/RelayStoreData.js +0 -660
  114. package/lib/RelayTaskQueue.js +0 -189
  115. package/lib/RelayTypes.js +0 -13
  116. package/lib/RelayVariable.js +0 -32
  117. package/lib/RelayVariables.js +0 -92
  118. package/lib/buildRQL.js +0 -160
  119. package/lib/callsFromGraphQL.js +0 -74
  120. package/lib/callsToGraphQL.js +0 -34
  121. package/lib/checkRelayQueryData.js +0 -250
  122. package/lib/createRelayQuery.js +0 -17
  123. package/lib/dedent.js +0 -49
  124. package/lib/diffRelayQuery.js +0 -757
  125. package/lib/directivesToGraphQL.js +0 -39
  126. package/lib/filterRelayQuery.js +0 -29
  127. package/lib/findRelayQueryLeaves.js +0 -293
  128. package/lib/flattenRelayQuery.js +0 -121
  129. package/lib/flattenSplitRelayQueries.js +0 -44
  130. package/lib/forEachRootCallArg.js +0 -40
  131. package/lib/fromGraphQL.js +0 -48
  132. package/lib/generateClientEdgeID.js +0 -22
  133. package/lib/generateClientID.js +0 -27
  134. package/lib/generateConcreteFragmentID.js +0 -30
  135. package/lib/generateForceIndex.js +0 -24
  136. package/lib/generateRQLFieldAlias.js +0 -39
  137. package/lib/getRangeBehavior.js +0 -58
  138. package/lib/getRelayQueries.js +0 -83
  139. package/lib/intersectRelayQuery.js +0 -149
  140. package/lib/isClassicRelayContext.js +0 -20
  141. package/lib/isClassicRelayEnvironment.js +0 -20
  142. package/lib/isCompatibleRelayFragmentType.js +0 -27
  143. package/lib/isRelayContainer.js +0 -16
  144. package/lib/makeLegacyStringishComponentRef.js +0 -52
  145. package/lib/printRelayOSSQuery.js +0 -329
  146. package/lib/printRelayQuery.js +0 -26
  147. package/lib/rangeOperationToMetadataKey.js +0 -25
  148. package/lib/readRelayQueryData.js +0 -551
  149. package/lib/relayUnstableBatchedUpdates.js +0 -12
  150. package/lib/relayUnstableBatchedUpdates.native.js +0 -11
  151. package/lib/restoreRelayCacheData.js +0 -188
  152. package/lib/serializeRelayQueryCall.js +0 -42
  153. package/lib/splitDeferredRelayQueries.js +0 -298
  154. package/lib/stableStringify.js +0 -85
  155. package/lib/testEditDistance.js +0 -112
  156. package/lib/throwFailedPromise.js +0 -26
  157. package/lib/toGraphQL.js +0 -94
  158. package/lib/transformRelayQueryPayload.js +0 -145
  159. package/lib/validateMutationConfig.js +0 -117
  160. package/lib/validateRelayReadQuery.js +0 -112
  161. package/lib/writeRelayQueryPayload.js +0 -44
  162. package/lib/writeRelayUpdatePayload.js +0 -513
  163. package/react-relay-classic.js +0 -4
  164. package/react-relay-classic.min.js +0 -9
  165. package/react-relay-compat.js +0 -4
  166. package/react-relay-compat.min.js +0 -9
@@ -1,39 +0,0 @@
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
- * strict-local
8
- * @format
9
- */
10
- 'use strict';
11
-
12
- /**
13
- * @internal
14
- *
15
- * Convert plain object `{name, arguments}` directives to GraphQL directive
16
- * nodes.
17
- */
18
- function directivesToGraphQL(directives) {
19
- return directives.map(function (_ref) {
20
- var directiveName = _ref.name,
21
- args = _ref.args;
22
- var concreteArguments = args.map(function (_ref2) {
23
- var argName = _ref2.name,
24
- value = _ref2.value;
25
- var concreteArgument = null;
26
-
27
- if (Array.isArray(value)) {
28
- concreteArgument = value.map(require("./QueryBuilder").createCallValue);
29
- } else if (value != null) {
30
- concreteArgument = require("./QueryBuilder").createCallValue(value);
31
- }
32
-
33
- return require("./QueryBuilder").createDirectiveArgument(argName, concreteArgument);
34
- });
35
- return require("./QueryBuilder").createDirective(directiveName, concreteArguments);
36
- });
37
- }
38
-
39
- module.exports = directivesToGraphQL;
@@ -1,29 +0,0 @@
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
- * strict-local
8
- * @format
9
- */
10
- 'use strict';
11
-
12
- /**
13
- * @internal
14
- *
15
- * `filterRelayQuery` filters query nodes for which `callback` returns false.
16
- * This is intended as a generic filter module and therefore contains no special
17
- * logic for handling requisite or generated fields.
18
- */
19
- function filterRelayQuery(node, callback) {
20
- if (callback(node)) {
21
- return node.clone(node.getChildren().map(function (child) {
22
- return filterRelayQuery(child, callback);
23
- }));
24
- }
25
-
26
- return null;
27
- }
28
-
29
- module.exports = filterRelayQuery;
@@ -1,293 +0,0 @@
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
- *
8
- * @format
9
- */
10
- 'use strict';
11
-
12
- var _inheritsLoose2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/inheritsLoose"));
13
-
14
- /**
15
- * @internal
16
- *
17
- * Traverses a query and data in the record store to determine if there are
18
- * additional nodes that needs to be read from disk cache. If it ncounters
19
- * a node that is not in `cachedRecords`, it will queued that node by adding it
20
- * into the `pendingNodeStates` list. If it encounters a node that was already read
21
- * but still missing data, then it will short circuit the evaluation since
22
- * there is no way for us to satisfy this query even with additional data from
23
- * disk cache and resturn
24
- */
25
- function findRelayQueryLeaves(store, cachedRecords, queryNode, dataID, path, rangeCalls) {
26
- var finder = new RelayQueryLeavesFinder(store, cachedRecords);
27
- var state = {
28
- dataID: dataID,
29
- missingData: false,
30
- path: path,
31
- rangeCalls: rangeCalls,
32
- rangeInfo: undefined
33
- };
34
- finder.visit(queryNode, state);
35
- return {
36
- missingData: state.missingData,
37
- pendingNodeStates: finder.getPendingNodeStates()
38
- };
39
- }
40
-
41
- var RelayQueryLeavesFinder =
42
- /*#__PURE__*/
43
- function (_RelayQueryVisitor) {
44
- (0, _inheritsLoose2["default"])(RelayQueryLeavesFinder, _RelayQueryVisitor);
45
-
46
- function RelayQueryLeavesFinder(store) {
47
- var _this;
48
-
49
- var cachedRecords = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
50
- _this = _RelayQueryVisitor.call(this) || this;
51
- _this._store = store;
52
- _this._cachedRecords = cachedRecords;
53
- _this._pendingNodeStates = [];
54
- return _this;
55
- }
56
-
57
- var _proto = RelayQueryLeavesFinder.prototype;
58
-
59
- _proto.getPendingNodeStates = function getPendingNodeStates() {
60
- return this._pendingNodeStates;
61
- };
62
- /**
63
- * Skip visiting children if missingData is already false.
64
- */
65
-
66
-
67
- _proto.traverse = function traverse(node, state) {
68
- var children = node.getChildren();
69
-
70
- for (var ii = 0; ii < children.length; ii++) {
71
- if (state.missingData) {
72
- return;
73
- }
74
-
75
- this.visit(children[ii], state);
76
- }
77
- };
78
-
79
- _proto.visitFragment = function visitFragment(fragment, state) {
80
- var dataID = state.dataID;
81
-
82
- var recordState = this._store.getRecordState(dataID);
83
-
84
- if (recordState === require("./RelayClassicRecordState").UNKNOWN) {
85
- this._handleMissingData(fragment, state);
86
-
87
- return;
88
- } else if (recordState === require("./RelayClassicRecordState").NONEXISTENT) {
89
- return;
90
- }
91
-
92
- if (require("./isCompatibleRelayFragmentType")(fragment, this._store.getType(dataID))) {
93
- this.traverse(fragment, state);
94
- }
95
- };
96
-
97
- _proto.visitField = function visitField(field, state) {
98
- var _ConnectionInterface$ = require("relay-runtime").ConnectionInterface.get(),
99
- EDGES = _ConnectionInterface$.EDGES,
100
- PAGE_INFO = _ConnectionInterface$.PAGE_INFO;
101
-
102
- var dataID = state.dataID;
103
-
104
- var recordState = this._store.getRecordState(dataID);
105
-
106
- if (recordState === require("./RelayClassicRecordState").UNKNOWN) {
107
- this._handleMissingData(field, state);
108
-
109
- return;
110
- } else if (recordState === require("./RelayClassicRecordState").NONEXISTENT) {
111
- return;
112
- }
113
-
114
- if (state.rangeCalls && !state.rangeInfo) {
115
- var metadata = this._store.getRangeMetadata(dataID, state.rangeCalls);
116
-
117
- if (metadata) {
118
- state.rangeInfo = metadata;
119
- }
120
- }
121
-
122
- var rangeInfo = state.rangeInfo;
123
-
124
- if (rangeInfo && field.getSchemaName() === EDGES) {
125
- this._visitEdges(field, state);
126
- } else if (rangeInfo && field.getSchemaName() === PAGE_INFO) {
127
- this._visitPageInfo(field, state);
128
- } else if (!field.canHaveSubselections()) {
129
- this._visitScalar(field, state);
130
- } else if (field.isPlural()) {
131
- this._visitPlural(field, state);
132
- } else if (field.isConnection()) {
133
- this._visitConnection(field, state);
134
- } else {
135
- this._visitLinkedField(field, state);
136
- }
137
- };
138
-
139
- _proto._visitScalar = function _visitScalar(field, state) {
140
- var fieldData = this._store.getField(state.dataID, field.getStorageKey());
141
-
142
- if (fieldData === undefined) {
143
- this._handleMissingData(field, state);
144
- }
145
- };
146
-
147
- _proto._visitPlural = function _visitPlural(field, state) {
148
- var dataIDs = this._store.getLinkedRecordIDs(state.dataID, field.getStorageKey());
149
-
150
- if (dataIDs === undefined) {
151
- this._handleMissingData(field, state);
152
-
153
- return;
154
- }
155
-
156
- if (dataIDs) {
157
- for (var ii = 0; ii < dataIDs.length; ii++) {
158
- if (state.missingData) {
159
- break;
160
- }
161
-
162
- var nextState = {
163
- dataID: dataIDs[ii],
164
- missingData: false,
165
- path: require("./RelayQueryPath").getPath(state.path, field, dataIDs[ii]),
166
- rangeCalls: undefined,
167
- rangeInfo: undefined
168
- };
169
- this.traverse(field, nextState);
170
- state.missingData = nextState.missingData;
171
- }
172
- }
173
- };
174
-
175
- _proto._visitConnection = function _visitConnection(field, state) {
176
- var calls = field.getCallsWithValues();
177
-
178
- var dataID = this._store.getLinkedRecordID(state.dataID, field.getStorageKey());
179
-
180
- if (dataID === undefined) {
181
- this._handleMissingData(field, state);
182
-
183
- return;
184
- }
185
-
186
- if (dataID) {
187
- var nextState = {
188
- dataID: dataID,
189
- missingData: false,
190
- path: require("./RelayQueryPath").getPath(state.path, field, dataID),
191
- rangeCalls: calls,
192
- rangeInfo: null
193
- };
194
-
195
- var metadata = this._store.getRangeMetadata(dataID, calls);
196
-
197
- if (metadata) {
198
- nextState.rangeInfo = metadata;
199
- }
200
-
201
- this.traverse(field, nextState);
202
- state.missingData = state.missingData || nextState.missingData;
203
- }
204
- };
205
-
206
- _proto._visitEdges = function _visitEdges(field, state) {
207
- var rangeInfo = state.rangeInfo; // Doesn't have `__range__` loaded
208
-
209
- if (!rangeInfo) {
210
- this._handleMissingData(field, state);
211
-
212
- return;
213
- }
214
-
215
- if (rangeInfo.diffCalls.length) {
216
- state.missingData = true;
217
- return;
218
- }
219
-
220
- var edgeIDs = rangeInfo.requestedEdgeIDs;
221
-
222
- for (var ii = 0; ii < edgeIDs.length; ii++) {
223
- if (state.missingData) {
224
- break;
225
- }
226
-
227
- var nextState = {
228
- dataID: edgeIDs[ii],
229
- missingData: false,
230
- path: require("./RelayQueryPath").getPath(state.path, field, edgeIDs[ii]),
231
- rangeCalls: undefined,
232
- rangeInfo: undefined
233
- };
234
- this.traverse(field, nextState);
235
- state.missingData = state.missingData || nextState.missingData;
236
- }
237
- };
238
-
239
- _proto._visitPageInfo = function _visitPageInfo(field, state) {
240
- var rangeInfo = state.rangeInfo;
241
-
242
- if (!rangeInfo || !rangeInfo.pageInfo) {
243
- this._handleMissingData(field, state);
244
-
245
- return;
246
- }
247
- };
248
-
249
- _proto._visitLinkedField = function _visitLinkedField(field, state) {
250
- var dataID = this._store.getLinkedRecordID(state.dataID, field.getStorageKey());
251
-
252
- if (dataID === undefined) {
253
- this._handleMissingData(field, state);
254
-
255
- return;
256
- }
257
-
258
- if (dataID) {
259
- var nextState = {
260
- dataID: dataID,
261
- missingData: false,
262
- path: require("./RelayQueryPath").getPath(state.path, field, dataID),
263
- rangeCalls: undefined,
264
- rangeInfo: undefined
265
- };
266
- this.traverse(field, nextState);
267
- state.missingData = state.missingData || nextState.missingData;
268
- }
269
- };
270
-
271
- _proto._handleMissingData = function _handleMissingData(node, state) {
272
- var dataID = state.dataID;
273
-
274
- if (this._cachedRecords.hasOwnProperty(dataID)) {
275
- // We have read data for this `dataID` from disk, but
276
- // we still don't have data for the relevant field.
277
- state.missingData = true;
278
- } else {
279
- // Store node in `pendingNodeStates` because we have not read data for
280
- // this `dataID` from disk.
281
- this._pendingNodeStates.push({
282
- dataID: dataID,
283
- node: node,
284
- path: state.path,
285
- rangeCalls: state.rangeCalls
286
- });
287
- }
288
- };
289
-
290
- return RelayQueryLeavesFinder;
291
- }(require("./RelayQueryVisitor"));
292
-
293
- module.exports = require("relay-runtime").RelayProfiler.instrument('findRelayQueryLeaves', findRelayQueryLeaves);
@@ -1,121 +0,0 @@
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
- * strict-local
8
- * @format
9
- */
10
- 'use strict';
11
-
12
- var _inheritsLoose2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/inheritsLoose"));
13
-
14
- /**
15
- * @internal
16
- *
17
- * `flattenRelayQuery(query)` returns a clone of `query` with fields inside of
18
- * fragments recursively flattened into the nearest ancestor field.
19
- *
20
- * The result can be null if `node` only contains empty fragments or fragments
21
- * that only contain empty fragments.
22
- */
23
- function flattenRelayQuery(node, options) {
24
- var flattener = new RelayQueryFlattener(options && options.shouldRemoveFragments);
25
- var state = {
26
- node: node,
27
- type: node.getType(),
28
- flattenedFieldMap: new Map(),
29
- flattenedFragmentMap: new Map()
30
- };
31
- flattener.traverse(node, state);
32
- return toQuery(node, state, !!(options && options.preserveEmptyNodes));
33
- }
34
-
35
- function toQuery(node, _ref, preserveEmptyNodes) {
36
- var flattenedFieldMap = _ref.flattenedFieldMap,
37
- flattenedFragmentMap = _ref.flattenedFragmentMap;
38
- var children = [];
39
- var aliases = Array.from(flattenedFieldMap.keys());
40
- aliases.forEach(function (alias) {
41
- var field = flattenedFieldMap.get(alias);
42
-
43
- if (field) {
44
- children.push(toQuery(field.node, field, preserveEmptyNodes));
45
- }
46
- });
47
- Array.from(flattenedFragmentMap.keys()).forEach(function (type) {
48
- var fragment = flattenedFragmentMap.get(type);
49
-
50
- if (fragment) {
51
- children.push(toQuery(fragment.node, fragment, preserveEmptyNodes));
52
- }
53
- }); // Pattern nodes may contain non-scalar fields without children that
54
- // should not be removed.
55
-
56
- if (preserveEmptyNodes && node.canHaveSubselections() && !children.length) {
57
- return node;
58
- }
59
-
60
- return node.clone(children);
61
- }
62
-
63
- var RelayQueryFlattener =
64
- /*#__PURE__*/
65
- function (_RelayQueryVisitor) {
66
- (0, _inheritsLoose2["default"])(RelayQueryFlattener, _RelayQueryVisitor);
67
-
68
- function RelayQueryFlattener(shouldRemoveFragments) {
69
- var _this;
70
-
71
- _this = _RelayQueryVisitor.call(this) || this;
72
- _this._shouldRemoveFragments = !!shouldRemoveFragments;
73
- return _this;
74
- }
75
-
76
- var _proto = RelayQueryFlattener.prototype;
77
-
78
- _proto.visitFragment = function visitFragment(node, state) {
79
- var type = node.getType();
80
-
81
- if (this._shouldRemoveFragments || type === state.type) {
82
- this.traverse(node, state);
83
- return;
84
- }
85
-
86
- var flattenedFragment = state.flattenedFragmentMap.get(type);
87
-
88
- if (!flattenedFragment) {
89
- flattenedFragment = {
90
- node: node,
91
- type: type,
92
- flattenedFieldMap: new Map(),
93
- flattenedFragmentMap: new Map()
94
- };
95
- state.flattenedFragmentMap.set(type, flattenedFragment);
96
- }
97
-
98
- this.traverse(node, flattenedFragment);
99
- };
100
-
101
- _proto.visitField = function visitField(node, state) {
102
- var hash = node.getShallowHash();
103
- var flattenedField = state.flattenedFieldMap.get(hash);
104
-
105
- if (!flattenedField) {
106
- flattenedField = {
107
- node: node,
108
- type: node.getType(),
109
- flattenedFieldMap: new Map(),
110
- flattenedFragmentMap: new Map()
111
- };
112
- state.flattenedFieldMap.set(hash, flattenedField);
113
- }
114
-
115
- this.traverse(node, flattenedField);
116
- };
117
-
118
- return RelayQueryFlattener;
119
- }(require("./RelayQueryVisitor"));
120
-
121
- module.exports = require("relay-runtime").RelayProfiler.instrument('flattenRelayQuery', flattenRelayQuery);
@@ -1,44 +0,0 @@
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
- *
8
- * @format
9
- */
10
- 'use strict';
11
-
12
- var _toConsumableArray2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/toConsumableArray"));
13
-
14
- /**
15
- * Flattens the nested structure returned by `splitDeferredRelayQueries`.
16
- *
17
- * Right now our internals discard the information about the relationship
18
- * between the queries that is encoded in the nested structure.
19
- *
20
- * @internal
21
- */
22
- function flattenSplitRelayQueries(splitQueries) {
23
- var flattenedQueries = [];
24
- var queue = [splitQueries];
25
-
26
- while (queue.length) {
27
- splitQueries = queue.shift();
28
- var _splitQueries = splitQueries,
29
- required = _splitQueries.required,
30
- deferred = _splitQueries.deferred;
31
-
32
- if (required) {
33
- flattenedQueries.push(required);
34
- }
35
-
36
- if (deferred.length) {
37
- queue.push.apply(queue, (0, _toConsumableArray2["default"])(deferred));
38
- }
39
- }
40
-
41
- return flattenedQueries;
42
- }
43
-
44
- module.exports = flattenSplitRelayQueries;
@@ -1,40 +0,0 @@
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
- * strict-local
8
- * @format
9
- */
10
- 'use strict';
11
-
12
- /**
13
- * @internal
14
- *
15
- * Iterates over the identifying arguments in the supplied root call.
16
- * If the identifying value is null or undefined, the supplied callback will be
17
- * invoked once.
18
- */
19
- function forEachRootCallArg(query, callback) {
20
- !!query.getBatchCall() ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'forEachRootCallArg(): Cannot iterate over batch call variables.') : require("fbjs/lib/invariant")(false) : void 0;
21
-
22
- function each(identifyingArgValue, fn) {
23
- if (Array.isArray(identifyingArgValue)) {
24
- identifyingArgValue.forEach(function (value) {
25
- return each(value, fn);
26
- });
27
- } else {
28
- fn({
29
- identifyingArgValue: identifyingArgValue,
30
- identifyingArgKey: identifyingArgValue == null ? null : typeof identifyingArgValue === 'string' ? identifyingArgValue : require("./stableStringify")(identifyingArgValue)
31
- });
32
- }
33
- }
34
-
35
- var identifyingArg = query.getIdentifyingArg();
36
- var identifyingArgValue = identifyingArg && identifyingArg.value || null;
37
- each(identifyingArgValue, callback);
38
- }
39
-
40
- module.exports = forEachRootCallArg;
@@ -1,48 +0,0 @@
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
- * strict-local
8
- * @format
9
- */
10
- 'use strict';
11
-
12
- /**
13
- * @internal
14
- *
15
- * Converts GraphQL nodes to RelayQuery nodes.
16
- */
17
- var fromGraphQL = {
18
- Field: function Field(query) {
19
- var node = createNode(query, require("./RelayQuery").Field);
20
- !(node instanceof require("./RelayQuery").Field) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'fromGraphQL.Field(): Expected a GraphQL field node.') : require("fbjs/lib/invariant")(false) : void 0;
21
- return node;
22
- },
23
- Fragment: function Fragment(query) {
24
- var node = createNode(query, require("./RelayQuery").Fragment);
25
- !(node instanceof require("./RelayQuery").Fragment) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'fromGraphQL.Fragment(): Expected a GraphQL fragment node.') : require("fbjs/lib/invariant")(false) : void 0;
26
- return node;
27
- },
28
- Query: function Query(query) {
29
- var node = createNode(query, require("./RelayQuery").Root);
30
- !(node instanceof require("./RelayQuery").Root) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'fromGraphQL.Query(): Expected a root node.') : require("fbjs/lib/invariant")(false) : void 0;
31
- return node;
32
- },
33
- Operation: function Operation(query) {
34
- var node = createNode(query, require("./RelayQuery").Operation);
35
- !(node instanceof require("./RelayQuery").Operation) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'fromGraphQL.Operation(): Expected a mutation/subscription node.') : require("fbjs/lib/invariant")(false) : void 0;
36
- return node;
37
- }
38
- };
39
-
40
- function createNode(query, desiredType) {
41
- var variables = {};
42
-
43
- var route = require("./RelayMetaRoute").get('$fromGraphQL');
44
-
45
- return desiredType.create(query, route, variables);
46
- }
47
-
48
- module.exports = fromGraphQL;
@@ -1,22 +0,0 @@
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
- * strict
8
- * @format
9
- */
10
- 'use strict';
11
- /**
12
- * Generate an edge client id for edges on connections based on the range it
13
- * belongs to and the node it contains.
14
- *
15
- * @internal
16
- */
17
-
18
- function generateClientEdgeID(rangeID, nodeID) {
19
- return 'client:' + rangeID + ':' + nodeID;
20
- }
21
-
22
- module.exports = generateClientEdgeID;
@@ -1,27 +0,0 @@
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
- * strict-local
8
- * @format
9
- */
10
- 'use strict';
11
-
12
- var _clientID = 1;
13
-
14
- var _prefix = 'client:' + require("fbjs/lib/crc32")('' + require("fbjs/lib/performanceNow")());
15
- /**
16
- * Generate a unique clientID for GraphQL data objects that do not already have
17
- * an ID or their ID = null
18
- *
19
- * @internal
20
- */
21
-
22
-
23
- function generateClientID() {
24
- return _prefix + _clientID++;
25
- }
26
-
27
- module.exports = generateClientID;
@@ -1,30 +0,0 @@
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
- * strict-local
8
- * @format
9
- */
10
- 'use strict';
11
-
12
- // Static ids always end with `:<HASH>` where HASH is an alphanumeric transform
13
- // of an auto-incrementing index. A double-colon is used to distinguish between
14
- // client ids and static ids that happen to hash to `:client`.
15
- var SUFFIX = '::client';
16
- var _nextFragmentID = 0;
17
- /**
18
- * The "concrete fragment id" uniquely identifies a Relay.QL`fragment ...`
19
- * within the source code of an application and will remain the same across
20
- * runs of a particular version of an application.
21
- *
22
- * This function can be used to generate a unique id for fragments constructed
23
- * at runtime and is guaranteed not to conflict with statically created ids.
24
- */
25
-
26
- function generateConcreteFragmentID() {
27
- return require("fbjs/lib/base62")(_nextFragmentID++) + SUFFIX;
28
- }
29
-
30
- module.exports = generateConcreteFragmentID;