react-relay 2.0.0-rc.2 → 5.0.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 (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
@@ -9,26 +9,38 @@
9
9
  */
10
10
  'use strict';
11
11
 
12
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
13
+
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+
16
+ var areEqual = require("fbjs/lib/areEqual");
17
+
18
+ var emptyFunction = require("fbjs/lib/emptyFunction");
19
+
20
+ var invariant = require("fbjs/lib/invariant");
21
+
22
+ var warning = require("fbjs/lib/warning");
23
+
24
+ var _require = require("relay-runtime"),
25
+ Network = _require.Network,
26
+ isRelayModernEnvironment = _require.isRelayModernEnvironment;
27
+
12
28
  /**
13
29
  * The next id to return from `generateId()`.
14
30
  */
15
31
  var nextId = 0;
16
- /**
17
- * The pending network fetches for the mocked network.
18
- */
19
-
20
- var pendingFetches = [];
21
32
 
22
33
  var ReactRelayTestMocker =
23
34
  /*#__PURE__*/
24
35
  function () {
25
36
  function ReactRelayTestMocker(env) {
26
- this._defaults = {};
37
+ (0, _defineProperty2["default"])(this, "_defaults", {});
38
+ (0, _defineProperty2["default"])(this, "_pendingFetches", []);
27
39
 
28
- if (require("relay-runtime").isRelayModernEnvironment(env)) {
40
+ if (isRelayModernEnvironment(env)) {
29
41
  this._mockNetworkLayer(env);
30
42
  } else {
31
- process.env.NODE_ENV !== "production" ? require("fbjs/lib/warning")(false, 'Netork mocking is currently only supported in Relay Modern. ' + 'You will not be able to resolve requests made with Relay ' + 'Classic environments.') : void 0;
43
+ process.env.NODE_ENV !== "production" ? warning(false, 'Netork mocking is currently only supported in Relay Modern. ' + 'You will not be able to resolve requests made with Relay ' + 'Classic environments.') : void 0;
32
44
  }
33
45
 
34
46
  this._environment = env;
@@ -45,7 +57,7 @@ function () {
45
57
  var toRet = nextId.toString();
46
58
  nextId++;
47
59
  return toRet;
48
- };
60
+ }
49
61
  /**
50
62
  * Create a unique identifier for a (query, variables) pair.
51
63
  * @param request: the request associated with the query
@@ -55,16 +67,16 @@ function () {
55
67
  * @returns a string which can later be used to uniquely identify this query
56
68
  * in the list of pending queries
57
69
  */
58
-
70
+ ;
59
71
 
60
72
  ReactRelayTestMocker.getIdentifier = function getIdentifier(request) {
61
73
  return request.name;
62
- };
74
+ }
63
75
  /**
64
76
  * Remove variables that we don't need from the query that will make it more
65
77
  * annoying to test (e.g. client_mutation_id, actor_id)
66
78
  */
67
-
79
+ ;
68
80
 
69
81
  ReactRelayTestMocker.stripUnused = function stripUnused(variables) {
70
82
  if (variables.input) {
@@ -75,7 +87,7 @@ function () {
75
87
  }
76
88
 
77
89
  return variables;
78
- };
90
+ }
79
91
  /**
80
92
  * Replace the environment's network layer with a mocked out one to allow for
81
93
  * better testing. Mocking the network allows testing without using a mocked
@@ -83,7 +95,7 @@ function () {
83
95
  * in refetch containers, for example. It also allows test writers to see how
84
96
  * their components behave under error conditions.
85
97
  */
86
-
98
+ ;
87
99
 
88
100
  var _proto = ReactRelayTestMocker.prototype;
89
101
 
@@ -91,10 +103,8 @@ function () {
91
103
  var _this = this;
92
104
 
93
105
  var fetch = function fetch(request, variables, cacheConfig) {
94
- var resolve = require("fbjs/lib/emptyFunction");
95
-
96
- var reject = require("fbjs/lib/emptyFunction");
97
-
106
+ var resolve = emptyFunction;
107
+ var reject = emptyFunction;
98
108
  var promise = new Promise(function (res, rej) {
99
109
  resolve = res;
100
110
  reject = rej;
@@ -107,7 +117,7 @@ function () {
107
117
  return typeof payload === 'function' ? payload(strippedVars) : payload;
108
118
  }
109
119
 
110
- pendingFetches.push({
120
+ _this._pendingFetches.push({
111
121
  ident: ident,
112
122
  cacheConfig: cacheConfig,
113
123
  deferred: {
@@ -117,30 +127,31 @@ function () {
117
127
  request: request,
118
128
  variables: variables
119
129
  });
130
+
120
131
  return promise;
121
132
  };
122
133
 
123
- function isLoading(ident) {
124
- return pendingFetches.some(function (pending) {
134
+ var isLoading = function isLoading(ident) {
135
+ return _this._pendingFetches.some(function (pending) {
125
136
  return pending.ident === ident;
126
137
  });
127
- }
138
+ };
128
139
 
129
- function resolveRawQuery(toResolve, payload) {
130
- pendingFetches = pendingFetches.filter(function (pending) {
140
+ var resolveRawQuery = function resolveRawQuery(toResolve, payload) {
141
+ _this._pendingFetches = _this._pendingFetches.filter(function (pending) {
131
142
  return pending !== toResolve;
132
143
  });
133
144
  var deferred = toResolve.deferred;
134
145
  deferred.resolve(payload);
135
- }
146
+ };
136
147
 
137
- function rejectQuery(toResolve, payload) {
138
- pendingFetches = pendingFetches.filter(function (pending) {
148
+ var rejectQuery = function rejectQuery(toResolve, payload) {
149
+ _this._pendingFetches = _this._pendingFetches.filter(function (pending) {
139
150
  return pending !== toResolve;
140
151
  });
141
152
  var deferred = toResolve.deferred;
142
153
  deferred.reject(payload.error);
143
- }
154
+ };
144
155
 
145
156
  env.mock = {
146
157
  isLoading: isLoading,
@@ -150,35 +161,35 @@ function () {
150
161
  };
151
162
  env.hasMockedNetwork = true;
152
163
 
153
- env.__setNet(require("relay-runtime").Network.create(fetch));
164
+ env.__setNet(Network.create(fetch));
154
165
 
155
166
  return env;
156
167
  };
157
168
 
158
169
  _proto._getDefaults = function _getDefaults() {
159
170
  return this._defaults;
160
- };
171
+ }
161
172
  /**
162
173
  * set a default payload for a given query
163
174
  */
164
-
175
+ ;
165
176
 
166
177
  _proto.setDefault = function setDefault(toSet) {
167
178
  var query = toSet.query,
168
179
  payload = toSet.payload;
169
180
  var ident = ReactRelayTestMocker.getIdentifier(query.params);
170
181
  this._defaults[ident] = payload;
171
- };
182
+ }
172
183
  /**
173
184
  * remove a default payload for a given query
174
185
  */
175
-
186
+ ;
176
187
 
177
188
  _proto.unsetDefault = function unsetDefault(toUnset) {
178
189
  var query = toUnset.query;
179
190
  var ident = ReactRelayTestMocker.getIdentifier(query.params);
180
191
  delete this._defaults[ident];
181
- };
192
+ }
182
193
  /**
183
194
  * Write directly to the Relay store instead of trying to resolve a query that
184
195
  * was sent via the network.
@@ -187,7 +198,7 @@ function () {
187
198
  * (via `createFragmentContainer`). The component under test should also be
188
199
  * wrapped in a `RelayTestRenderer`.
189
200
  */
190
-
201
+ ;
191
202
 
192
203
  _proto.dataWrite = function dataWrite(config) {
193
204
  var query = config.query,
@@ -195,10 +206,10 @@ function () {
195
206
  payload = config.payload;
196
207
  var createOperationDescriptor = this._environment.unstable_internal.createOperationDescriptor;
197
208
  var operationDescriptor = createOperationDescriptor(query, variables);
198
- !(payload.data != null && payload.errors === undefined) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'Only `data` can be written when using `writeDirect`. You may need to ' + 'wrap your payload in an object like `{data: payload}`.') : require("fbjs/lib/invariant")(false) : void 0;
209
+ !(payload.data != null && payload.errors === undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Only `data` can be written when using `writeDirect`. You may need to ' + 'wrap your payload in an object like `{data: payload}`.') : invariant(false) : void 0;
199
210
 
200
211
  this._environment.commitPayload(operationDescriptor, payload.data);
201
- };
212
+ }
202
213
  /**
203
214
  * Write the data specified in config's payload to the instance's environment.
204
215
  * NOTE: callers may need to invoke `jest.runOnlyPendingTimers()` after
@@ -207,10 +218,10 @@ function () {
207
218
  * @param config: an object containing the data to write and the query and
208
219
  * variables that the payload is simulating a response to
209
220
  */
210
-
221
+ ;
211
222
 
212
223
  _proto.networkWrite = function networkWrite(config) {
213
- !this._environment.hasMockedNetwork ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'You cannot resolve queries without a mocked environment. Did you mean ' + 'to use `writeDirect` instead?') : require("fbjs/lib/invariant")(false) : void 0;
224
+ !this._environment.hasMockedNetwork ? process.env.NODE_ENV !== "production" ? invariant(false, 'You cannot resolve queries without a mocked environment. Did you mean ' + 'to use `writeDirect` instead?') : invariant(false) : void 0;
214
225
  var query = config.query,
215
226
  variables = config.variables,
216
227
  payload = config.payload;
@@ -224,14 +235,15 @@ function () {
224
235
  }
225
236
 
226
237
  var toResolve;
227
- pendingFetches.forEach(function (pending) {
238
+
239
+ this._pendingFetches.forEach(function (pending) {
228
240
  var pendingVars = pending.variables;
229
241
 
230
242
  if (pending.ident === ident) {
231
- !(!toResolve || variables) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'Multiple queries with the same name are currently pending. You ' + 'should pass variables to `write` so that it can determine which ' + 'to resolve') : require("fbjs/lib/invariant")(false) : void 0;
243
+ !(!toResolve || variables) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Multiple queries with the same name are currently pending. You ' + 'should pass variables to `write` so that it can determine which ' + 'to resolve') : invariant(false) : void 0;
232
244
 
233
245
  if (variables) {
234
- if (require("fbjs/lib/areEqual")(pendingVars, usedVars)) {
246
+ if (areEqual(pendingVars, usedVars)) {
235
247
  toResolve = pending;
236
248
  }
237
249
  } else {
@@ -239,8 +251,9 @@ function () {
239
251
  }
240
252
  }
241
253
  });
254
+
242
255
  var varMessage = usedVars ? ' - variables: ' + JSON.stringify(usedVars) : '';
243
- !toResolve ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'You are attempting to resolve a query that has not been fetched ' + '(%s%s).\n\tPlease ensure you passed the correct variables, or use ' + '`writeDirect` instead.', ident, varMessage) : require("fbjs/lib/invariant")(false) : void 0;
256
+ !toResolve ? process.env.NODE_ENV !== "production" ? invariant(false, 'You are attempting to resolve a query that has not been fetched ' + '(%s%s).\n\tPlease ensure you passed the correct variables, or use ' + '`writeDirect` instead.', ident, varMessage) : invariant(false) : void 0;
244
257
  var realPayload = typeof payload === 'function' ? payload(toResolve.variables) : payload; // if there are errors, reject the query
245
258
 
246
259
  if (realPayload.errors != null && realPayload.errors.length > 0) {
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * strict-local
7
+ *
8
8
  * @format
9
9
  */
10
10
  'use strict';
@@ -9,12 +9,18 @@
9
9
  */
10
10
  'use strict';
11
11
 
12
+ var invariant = require("fbjs/lib/invariant");
13
+
14
+ var isRelayEnvironment = require("./isRelayEnvironment");
15
+
16
+ var isRelayVariables = require("./isRelayVariables");
17
+
12
18
  /**
13
19
  * Asserts that the input is a matches the `RelayContext` type defined in
14
20
  * `RelayEnvironmentTypes` and returns it as that type.
15
21
  */
16
22
  function assertRelayContext(relay) {
17
- !isRelayContext(relay) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayContext: Expected `context.relay` to be an object conforming to ' + 'the `RelayContext` interface, got `%s`.', relay) : require("fbjs/lib/invariant")(false) : void 0;
23
+ !isRelayContext(relay) ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayContext: Expected `context.relay` to be an object conforming to ' + 'the `RelayContext` interface, got `%s`.', relay) : invariant(false) : void 0;
18
24
  return relay;
19
25
  }
20
26
  /**
@@ -24,7 +30,7 @@ function assertRelayContext(relay) {
24
30
 
25
31
 
26
32
  function isRelayContext(context) {
27
- return typeof context === 'object' && context !== null && !Array.isArray(context) && require("./isRelayEnvironment")(context.environment) && require("./isRelayVariables")(context.variables);
33
+ return typeof context === 'object' && context !== null && !Array.isArray(context) && isRelayEnvironment(context.environment) && isRelayVariables(context.variables);
28
34
  }
29
35
 
30
36
  module.exports = {
@@ -4,21 +4,23 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * strict-local
7
+ *
8
8
  * @format
9
9
  */
10
10
  'use strict';
11
11
 
12
+ var invariant = require("fbjs/lib/invariant");
13
+
12
14
  /**
13
15
  * Fail fast if the user supplies invalid fragments as input.
14
16
  */
15
- function assertFragmentMap(componentName, fragments) {
16
- !(fragments && typeof fragments === 'object') ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'Could not create Relay Container for `%s`. ' + 'Expected a set of GraphQL fragments, got `%s` instead.', componentName, fragments) : require("fbjs/lib/invariant")(false) : void 0;
17
+ function assertFragmentMap(componentName, fragmentSpec) {
18
+ !(fragmentSpec && typeof fragmentSpec === 'object') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not create Relay Container for `%s`. ' + 'Expected a set of GraphQL fragments, got `%s` instead.', componentName, fragmentSpec) : invariant(false) : void 0;
17
19
 
18
- for (var key in fragments) {
19
- if (fragments.hasOwnProperty(key)) {
20
- var fragment = fragments[key];
21
- !(fragment && (typeof fragment === 'object' || typeof fragment === 'function')) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'Could not create Relay Container for `%s`. ' + 'The value of fragment `%s` was expected to be a fragment, got `%s` instead.', componentName, key, fragment) : require("fbjs/lib/invariant")(false) : void 0;
20
+ for (var key in fragmentSpec) {
21
+ if (fragmentSpec.hasOwnProperty(key)) {
22
+ var fragment = fragmentSpec[key];
23
+ !(fragment && (typeof fragment === 'object' || typeof fragment === 'function')) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Could not create Relay Container for `%s`. ' + 'The value of fragment `%s` was expected to be a fragment, got `%s` instead.', componentName, key, fragment) : invariant(false) : void 0;
22
24
  }
23
25
  }
24
26
  }
@@ -9,7 +9,25 @@
9
9
  */
10
10
  'use strict';
11
11
 
12
- var _extends2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/extends"));
12
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
13
+
14
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
15
+
16
+ var React = require("react");
17
+
18
+ var ReactRelayContext = require("./ReactRelayContext");
19
+
20
+ var assertFragmentMap = require("./assertFragmentMap");
21
+
22
+ var invariant = require("fbjs/lib/invariant");
23
+
24
+ var mapObject = require("fbjs/lib/mapObject");
25
+
26
+ var readContext = require("./readContext");
27
+
28
+ var _require = require("./ReactRelayContainerUtils"),
29
+ getComponentName = _require.getComponentName,
30
+ getContainerName = _require.getContainerName;
13
31
 
14
32
  /**
15
33
  * Creates a component class whose instances adapt to the
@@ -19,10 +37,8 @@ var _extends2 = require("@babel/runtime/helpers/interopRequireDefault")(require(
19
37
  */
20
38
  function buildReactRelayContainer(ComponentClass, fragmentSpec, createContainerWithFragments) {
21
39
  // Sanity-check user-defined fragment input
22
- var containerName = require("./ReactRelayContainerUtils").getContainerName(ComponentClass);
23
-
24
- require("./assertFragmentMap")(require("./ReactRelayContainerUtils").getComponentName(ComponentClass), fragmentSpec); // Memoize a container for the last environment instance encountered
25
-
40
+ var containerName = getContainerName(ComponentClass);
41
+ assertFragmentMap(getComponentName(ComponentClass), fragmentSpec); // Memoize a container for the last environment instance encountered
26
42
 
27
43
  var environment;
28
44
  var Container;
@@ -36,13 +52,13 @@ function buildReactRelayContainer(ComponentClass, fragmentSpec, createContainerW
36
52
  isRelayModernEnvironment = _require2.isRelayModernEnvironment;
37
53
 
38
54
  if (!isRelayModernEnvironment(environment)) {
39
- throw new Error('RelayModernContainer: Can only use Relay Modern component ' + "".concat(containerName, " in a Relay Modern environment!\n") + 'When using Relay Modern and Relay Classic in the same ' + 'application, ensure components use Relay Compat to work in ' + 'both environments.\n' + 'See: http://facebook.github.io/relay/docs/relay-compat.html');
55
+ throw new Error('RelayModernContainer: Can only use Relay Modern component ' + "".concat(containerName, " in a Relay Modern environment!"));
40
56
  }
41
57
  }
42
58
 
43
59
  var getFragmentFromTag = environment.unstable_internal.getFragment;
44
60
 
45
- var _fragments = require("fbjs/lib/mapObject")(fragmentSpec, getFragmentFromTag);
61
+ var _fragments = mapObject(fragmentSpec, getFragmentFromTag);
46
62
 
47
63
  Container = createContainerWithFragments(ComponentClass, _fragments); // Attach static lifecycle to wrapper component so React can see it.
48
64
 
@@ -53,31 +69,24 @@ function buildReactRelayContainer(ComponentClass, fragmentSpec, createContainerW
53
69
  return new Container(props);
54
70
  }
55
71
 
56
- function forwardRef(props, ref) {
57
- var context = require("./readContext")(require("./ReactRelayContext"));
72
+ ContainerConstructor.prototype = React.Component.prototype;
73
+ ContainerConstructor.displayName = containerName;
58
74
 
59
- !context ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, "".concat(containerName, " tried to render a context that was ") + "not valid this means that ".concat(containerName, " was rendered outside of a ") + 'query renderer.') : require("fbjs/lib/invariant")(false) : void 0;
60
- return require("react").createElement(ContainerConstructor, (0, _extends2["default"])({}, props, {
75
+ function forwardRef(props, ref) {
76
+ var context = readContext(ReactRelayContext);
77
+ !context ? process.env.NODE_ENV !== "production" ? invariant(false, "".concat(containerName, " tried to render a context that was ") + "not valid this means that ".concat(containerName, " was rendered outside of a ") + 'query renderer.') : invariant(false) : void 0;
78
+ return React.createElement(ContainerConstructor, (0, _extends2["default"])({}, props, {
61
79
  __relayContext: context,
62
80
  componentRef: props.componentRef || ref
63
81
  }));
64
82
  }
65
83
 
66
84
  forwardRef.displayName = containerName;
67
-
68
- var ForwardContainer = require("react").forwardRef(forwardRef);
85
+ var ForwardContainer = React.forwardRef(forwardRef);
69
86
 
70
87
  if (process.env.NODE_ENV !== "production") {
71
- /* $FlowFixMe(>=0.89.0 site=www,mobile,react_native_fb,oss) Suppressing
72
- * errors found while preparing to upgrade to 0.89.0 */
73
- ForwardContainer.__ComponentClass = ComponentClass; // Classic container static methods.
74
-
75
- /* $FlowFixMe(>=0.89.0 site=www,mobile,react_native_fb,oss) Suppressing
76
- * errors found while preparing to upgrade to 0.89.0 */
77
-
78
- ForwardContainer.getFragment = function getFragmentOnModernContainer() {
79
- throw new Error("RelayModernContainer: ".concat(containerName, ".getFragment() was called on ") + 'a Relay Modern component by a Relay Classic or Relay Compat ' + 'component.\n' + 'When using Relay Modern and Relay Classic in the same ' + 'application, ensure components use Relay Compat to work in ' + 'both environments.\n' + 'See: http://facebook.github.io/relay/docs/relay-compat.html');
80
- };
88
+ // Used by RelayModernTestUtils
89
+ ForwardContainer.__ComponentClass = ComponentClass;
81
90
  }
82
91
  /* $FlowFixMe(>=0.89.0 site=www,mobile,react_native_fb,oss) Suppressing errors
83
92
  * found while preparing to upgrade to 0.89.0 */
package/lib/index.js ADDED
@@ -0,0 +1,41 @@
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 ReactRelayContext = require("./ReactRelayContext");
13
+
14
+ var ReactRelayFragmentContainer = require("./ReactRelayFragmentContainer");
15
+
16
+ var ReactRelayPaginationContainer = require("./ReactRelayPaginationContainer");
17
+
18
+ var ReactRelayQueryRenderer = require("./ReactRelayQueryRenderer");
19
+
20
+ var ReactRelayRefetchContainer = require("./ReactRelayRefetchContainer");
21
+
22
+ var RelayRuntime = require("relay-runtime");
23
+
24
+ /**
25
+ * The public interface to React Relay.
26
+ */
27
+ module.exports = {
28
+ QueryRenderer: ReactRelayQueryRenderer,
29
+ MutationTypes: RelayRuntime.MutationTypes,
30
+ RangeOperations: RelayRuntime.RangeOperations,
31
+ ReactRelayContext: ReactRelayContext,
32
+ applyOptimisticMutation: RelayRuntime.applyOptimisticMutation,
33
+ commitLocalUpdate: RelayRuntime.commitLocalUpdate,
34
+ commitMutation: RelayRuntime.commitMutation,
35
+ createFragmentContainer: ReactRelayFragmentContainer.createContainer,
36
+ createPaginationContainer: ReactRelayPaginationContainer.createContainer,
37
+ createRefetchContainer: ReactRelayRefetchContainer.createContainer,
38
+ fetchQuery: RelayRuntime.fetchQuery,
39
+ graphql: RelayRuntime.graphql,
40
+ requestSubscription: RelayRuntime.requestSubscription
41
+ };
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * strict
7
+ *
8
8
  * @format
9
9
  */
10
10
  'use strict';
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * strict
7
+ *
8
8
  * @format
9
9
  */
10
10
  'use strict';
@@ -4,16 +4,19 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * strict-local
7
+ *
8
8
  * @format
9
9
  */
10
10
  'use strict';
11
11
 
12
- var ReactCurrentDispatcher =
12
+ var React = require("react");
13
+
14
+ var _React$__SECRET_INTER =
13
15
  /* $FlowFixMe Flow doesn't know about React's internals for good reason,
14
16
  but for now, Relay needs the dispatcher to read context. */
15
- require("react").__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher,
16
- ReactCurrentOwner = require("react").__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner;
17
+ React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
18
+ ReactCurrentDispatcher = _React$__SECRET_INTER.ReactCurrentDispatcher,
19
+ ReactCurrentOwner = _React$__SECRET_INTER.ReactCurrentOwner;
17
20
 
18
21
  function readContext(Context) {
19
22
  var dispatcher = ReactCurrentDispatcher != null ? ReactCurrentDispatcher.current : ReactCurrentOwner.currentDispatcher;
package/package.json CHANGED
@@ -1,22 +1,21 @@
1
1
  {
2
2
  "name": "react-relay",
3
3
  "description": "A framework for building GraphQL-driven React applications.",
4
- "version": "2.0.0-rc.2",
4
+ "version": "5.0.0",
5
5
  "keywords": [
6
6
  "graphql",
7
7
  "relay",
8
8
  "react"
9
9
  ],
10
10
  "license": "MIT",
11
- "homepage": "https://facebook.github.io/relay/",
11
+ "homepage": "https://relay.dev",
12
12
  "bugs": "https://github.com/facebook/relay/issues",
13
13
  "repository": "facebook/relay",
14
14
  "dependencies": {
15
15
  "@babel/runtime": "^7.0.0",
16
16
  "fbjs": "^1.0.0",
17
17
  "nullthrows": "^1.1.0",
18
- "prop-types": "^15.5.8",
19
- "relay-runtime": "2.0.0-rc.2"
18
+ "relay-runtime": "5.0.0"
20
19
  },
21
20
  "peerDependencies": {
22
21
  "react": "^16.5.0"
@@ -24,5 +23,6 @@
24
23
  "directories": {
25
24
  "": "./"
26
25
  },
26
+ "main": "index.js",
27
27
  "haste_commonjs": true
28
28
  }