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,250 +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 whether we have
18
- * enough data to satisfy the query.
19
- */
20
- function checkRelayQueryData(store, query) {
21
- var checker = new RelayQueryChecker(store);
22
- var state = {
23
- dataID: undefined,
24
- rangeInfo: undefined,
25
- result: true
26
- };
27
- checker.visit(query, state);
28
- return state.result;
29
- }
30
-
31
- var RelayQueryChecker =
32
- /*#__PURE__*/
33
- function (_RelayQueryVisitor) {
34
- (0, _inheritsLoose2["default"])(RelayQueryChecker, _RelayQueryVisitor);
35
-
36
- function RelayQueryChecker(store) {
37
- var _this;
38
-
39
- _this = _RelayQueryVisitor.call(this) || this;
40
- _this._store = store;
41
- return _this;
42
- }
43
- /**
44
- * Skip visiting children if result is already false.
45
- */
46
-
47
-
48
- var _proto = RelayQueryChecker.prototype;
49
-
50
- _proto.traverse = function traverse(node, state) {
51
- var children = node.getChildren();
52
-
53
- for (var ii = 0; ii < children.length; ii++) {
54
- if (!state.result) {
55
- return;
56
- }
57
-
58
- this.visit(children[ii], state);
59
- }
60
- };
61
-
62
- _proto.visitRoot = function visitRoot(root, state) {
63
- var _this2 = this;
64
-
65
- var storageKey = root.getStorageKey();
66
-
67
- require("./forEachRootCallArg")(root, function (_ref) {
68
- var identifyingArgKey = _ref.identifyingArgKey;
69
-
70
- var dataID = _this2._store.getDataID(storageKey, identifyingArgKey);
71
-
72
- if (dataID == null) {
73
- state.result = false;
74
- } else {
75
- var nextState = {
76
- dataID: dataID,
77
- rangeInfo: undefined,
78
- result: true
79
- };
80
-
81
- _this2.traverse(root, nextState);
82
-
83
- state.result = state.result && nextState.result;
84
- }
85
- });
86
- };
87
-
88
- _proto.visitFragment = function visitFragment(fragment, state) {
89
- var dataID = state.dataID; // The dataID check is for Flow; it must be non-null to have gotten here.
90
-
91
- if (dataID && require("./isCompatibleRelayFragmentType")(fragment, this._store.getType(dataID))) {
92
- this.traverse(fragment, state);
93
- }
94
- };
95
-
96
- _proto.visitField = function visitField(field, state) {
97
- var dataID = state.dataID;
98
-
99
- var recordState = dataID && this._store.getRecordState(dataID);
100
-
101
- if (recordState === require("./RelayClassicRecordState").UNKNOWN) {
102
- state.result = false;
103
- return;
104
- } else if (recordState === require("./RelayClassicRecordState").NONEXISTENT) {
105
- return;
106
- }
107
-
108
- var _ConnectionInterface$ = require("relay-runtime").ConnectionInterface.get(),
109
- EDGES = _ConnectionInterface$.EDGES,
110
- PAGE_INFO = _ConnectionInterface$.PAGE_INFO;
111
-
112
- var rangeInfo = state.rangeInfo;
113
-
114
- if (rangeInfo && field.getSchemaName() === EDGES) {
115
- this._checkEdges(field, state);
116
- } else if (rangeInfo && field.getSchemaName() === PAGE_INFO) {
117
- this._checkPageInfo(field, state);
118
- } else if (!field.canHaveSubselections()) {
119
- this._checkScalar(field, state);
120
- } else if (field.isPlural()) {
121
- this._checkPlural(field, state);
122
- } else if (field.isConnection()) {
123
- this._checkConnection(field, state);
124
- } else {
125
- this._checkLinkedField(field, state);
126
- }
127
- };
128
-
129
- _proto._checkScalar = function _checkScalar(field, state) {
130
- var fieldData = state.dataID && this._store.getField(state.dataID, field.getStorageKey());
131
-
132
- if (fieldData === undefined) {
133
- state.result = false;
134
- }
135
- };
136
-
137
- _proto._checkPlural = function _checkPlural(field, state) {
138
- var dataIDs = state.dataID && this._store.getLinkedRecordIDs(state.dataID, field.getStorageKey());
139
-
140
- if (dataIDs === undefined) {
141
- state.result = false;
142
- return;
143
- }
144
-
145
- if (dataIDs) {
146
- for (var ii = 0; ii < dataIDs.length; ii++) {
147
- if (!state.result) {
148
- break;
149
- }
150
-
151
- var nextState = {
152
- dataID: dataIDs[ii],
153
- rangeInfo: undefined,
154
- result: true
155
- };
156
- this.traverse(field, nextState);
157
- state.result = nextState.result;
158
- }
159
- }
160
- };
161
-
162
- _proto._checkConnection = function _checkConnection(field, state) {
163
- var calls = field.getCallsWithValues();
164
-
165
- var dataID = state.dataID && this._store.getLinkedRecordID(state.dataID, field.getStorageKey());
166
-
167
- if (dataID === undefined) {
168
- state.result = false;
169
- return;
170
- }
171
-
172
- var nextState = {
173
- dataID: dataID,
174
- rangeInfo: null,
175
- // Flow rejects `undefined` here
176
- result: true
177
- };
178
-
179
- var metadata = this._store.getRangeMetadata(dataID, calls);
180
-
181
- if (metadata) {
182
- nextState.rangeInfo = metadata;
183
- }
184
-
185
- this.traverse(field, nextState);
186
- state.result = state.result && nextState.result;
187
- };
188
-
189
- _proto._checkEdges = function _checkEdges(field, state) {
190
- var rangeInfo = state.rangeInfo;
191
-
192
- if (!rangeInfo) {
193
- state.result = false;
194
- return;
195
- }
196
-
197
- if (rangeInfo.diffCalls.length) {
198
- state.result = false;
199
- return;
200
- }
201
-
202
- var edges = rangeInfo.filteredEdges;
203
-
204
- for (var ii = 0; ii < edges.length; ii++) {
205
- if (!state.result) {
206
- break;
207
- }
208
-
209
- var nextState = {
210
- dataID: edges[ii].edgeID,
211
- rangeInfo: undefined,
212
- result: true
213
- };
214
- this.traverse(field, nextState);
215
- state.result = nextState.result;
216
- }
217
- };
218
-
219
- _proto._checkPageInfo = function _checkPageInfo(field, state) {
220
- var rangeInfo = state.rangeInfo;
221
-
222
- if (!rangeInfo || !rangeInfo.pageInfo) {
223
- state.result = false;
224
- return;
225
- }
226
- };
227
-
228
- _proto._checkLinkedField = function _checkLinkedField(field, state) {
229
- var dataID = state.dataID && this._store.getLinkedRecordID(state.dataID, field.getStorageKey());
230
-
231
- if (dataID === undefined) {
232
- state.result = false;
233
- return;
234
- }
235
-
236
- if (dataID) {
237
- var nextState = {
238
- dataID: dataID,
239
- rangeInfo: undefined,
240
- result: true
241
- };
242
- this.traverse(field, nextState);
243
- state.result = state.result && nextState.result;
244
- }
245
- };
246
-
247
- return RelayQueryChecker;
248
- }(require("./RelayQueryVisitor"));
249
-
250
- module.exports = require("relay-runtime").RelayProfiler.instrument('checkRelayQueryData', checkRelayQueryData);
@@ -1,17 +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
- function createRelayQuery(node, variables) {
13
- !(typeof variables === 'object' && variables != null && !Array.isArray(variables)) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'Relay.Query: Expected `variables` to be an object.') : require("fbjs/lib/invariant")(false) : void 0;
14
- return require("./RelayQuery").Root.create(node, require("./RelayMetaRoute").get('$createRelayQuery'), variables);
15
- }
16
-
17
- module.exports = createRelayQuery;
package/lib/dedent.js DELETED
@@ -1,49 +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
- * Strips leading indentation from a multi-line string, enabling you to use
13
- * template literals in tests while maintaining nice nesting.
14
- *
15
- * An optional padding string can be supplied to force a fixed indent to be
16
- * applied back after stripping.
17
- */
18
-
19
- function dedent(string) {
20
- var padding = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
21
- var blankLine = /^\s*$/;
22
- var lines = string.split('\n'); // Remove any entirely blank leading or trailing lines.
23
-
24
- if (lines.length && lines[0].match(blankLine)) {
25
- lines.shift();
26
- }
27
-
28
- if (lines.length && lines[lines.length - 1].match(blankLine)) {
29
- lines.pop();
30
- }
31
-
32
- var minLeadingSpace = lines.reduce(function (acc, line) {
33
- if (line.match(blankLine)) {
34
- return acc;
35
- }
36
-
37
- var leadingWhitespace = line.match(/^(\s*)/);
38
- return Math.min(acc, leadingWhitespace ? leadingWhitespace[1].length : 0);
39
- }, Infinity);
40
- return lines.map(function (line) {
41
- if (line.match(blankLine)) {
42
- return '';
43
- }
44
-
45
- return padding + line.slice(minLeadingSpace);
46
- }).join('\n');
47
- }
48
-
49
- module.exports = dedent;