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,288 +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 _defineProperty2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/defineProperty"));
13
-
14
- var _objectSpread4 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/objectSpread"));
15
-
16
- var COUNTER_PREFIX = 'RelayGraphQLMutation';
17
- var collisionIDCounter = 0;
18
- /**
19
- * @public
20
- *
21
- * Low-level API for modeling a GraphQL mutation.
22
- *
23
- * This is the lowest level of abstraction at which product code may deal with
24
- * mutations in Relay, and it corresponds to the mutation operation ("a write
25
- * followed by a fetch") described in the GraphQL Specification. You specify
26
- * the mutation, the inputs, and the query.
27
- *
28
- * (There is an even lower-level representation, `RelayMutationRequest`,
29
- * underlying this which is an entirely internal implementation detail that
30
- * product code need not be aware of.)
31
- *
32
- * @see http://facebook.github.io/graphql/.
33
- *
34
- */
35
-
36
- var RelayGraphQLMutation =
37
- /*#__PURE__*/
38
- function () {
39
- /**
40
- * Simplest method for creating a RelayGraphQLMutation instance from a static
41
- * `mutation`, some `variables` and an `environment`.
42
- */
43
- RelayGraphQLMutation.create = function create(mutation, variables, environment) {
44
- return new RelayGraphQLMutation(mutation, variables, null, environment);
45
- };
46
- /**
47
- * Specialized method for creating RelayGraphQLMutation instances that takes a
48
- * `files` object in addition to the base `mutation`, `variables` and
49
- * `environment` parameters.
50
- */
51
-
52
-
53
- RelayGraphQLMutation.createWithFiles = function createWithFiles(mutation, variables, files, environment) {
54
- return new RelayGraphQLMutation(mutation, variables, files, environment);
55
- };
56
- /**
57
- * General constructor for creating RelayGraphQLMutation instances with
58
- * optional `files`, `callbacks` and `collisionKey` arguments.
59
- *
60
- * Callers must provide an appropriate `mutation`:
61
- *
62
- * Relay.QL`
63
- * mutation StoryLikeQuery {
64
- * likeStory(input: $input) {
65
- * clientMutationId
66
- * story {
67
- * likeCount
68
- * likers {
69
- * actor {
70
- * name
71
- * }
72
- * }
73
- * }
74
- * }
75
- * }
76
- * `;
77
- *
78
- * And set of `variables`:
79
- *
80
- * {
81
- * input: {
82
- * feedbackId: 'aFeedbackId',
83
- * },
84
- * }
85
- *
86
- * As per the GraphQL Relay Specification:
87
- *
88
- * - The mutation should take a single argument named "input".
89
- * - That input argument should contain a (string) "clientMutationId" property
90
- * for the purposes of reconciling requests and responses (automatically
91
- * added by the RelayGraphQLMutation API).
92
- * - The query should request "clientMutationId" as a subselection.
93
- *
94
- * @see http://facebook.github.io/relay/docs/graphql-mutations.html
95
- * @see http://facebook.github.io/relay/graphql/mutations.htm
96
- *
97
- * If not supplied, a unique collision key is derived (meaning that the
98
- * created mutation will be independent and not collide with any other).
99
- */
100
-
101
-
102
- function RelayGraphQLMutation(query, variables, files, environment, callbacks, collisionKey) {
103
- this._query = query;
104
- this._variables = variables;
105
- this._files = files || null;
106
- this._environment = environment;
107
- this._callbacks = callbacks || null;
108
- this._collisionKey = collisionKey || "".concat(COUNTER_PREFIX, ":collisionKey:").concat(getNextCollisionID());
109
- this._transaction = null;
110
- }
111
- /**
112
- * Call this to optimistically apply an update to the store.
113
- *
114
- * The optional `config` parameter can be used to configure a `RANGE_ADD` type
115
- * mutation, similar to `RelayMutation` API.
116
- *
117
- * Optionally, follow up with a call to `commit()` to send the mutation
118
- * to the server.
119
- *
120
- * Note: An optimistic update may only be applied once.
121
- */
122
-
123
-
124
- var _proto = RelayGraphQLMutation.prototype;
125
-
126
- _proto.applyOptimistic = function applyOptimistic(optimisticQuery, optimisticResponse, configs) {
127
- !!this._transaction ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayGraphQLMutation: `applyOptimistic()` was called on an instance ' + 'that already has a transaction in progress.') : require("fbjs/lib/invariant")(false) : void 0;
128
- this._transaction = this._createTransaction(optimisticQuery, optimisticResponse);
129
- return this._transaction.applyOptimistic(configs);
130
- };
131
- /**
132
- * Call this to send the mutation to the server.
133
- *
134
- * The optional `config` parameter can be used to configure a `RANGE_ADD` type
135
- * mutation, similar to the `RelayMutation` API.
136
- *
137
- * Optionally, precede with a call to `applyOptimistic()` to apply an update
138
- * optimistically to the store.
139
- *
140
- * Note: This method may only be called once per instance.
141
- */
142
-
143
-
144
- _proto.commit = function commit(configs) {
145
- if (!this._transaction) {
146
- this._transaction = this._createTransaction();
147
- }
148
-
149
- return this._transaction.commit(configs);
150
- };
151
-
152
- _proto.rollback = function rollback() {
153
- if (this._transaction) {
154
- return this._transaction.rollback();
155
- }
156
- };
157
-
158
- _proto._createTransaction = function _createTransaction(optimisticQuery, optimisticResponse) {
159
- return new PendingGraphQLTransaction(this._environment, this._query, this._variables, this._files, optimisticQuery, optimisticResponse, this._collisionKey, this._callbacks);
160
- };
161
-
162
- return RelayGraphQLMutation;
163
- }();
164
-
165
- function getNextCollisionID() {
166
- return collisionIDCounter++;
167
- }
168
- /**
169
- * @internal
170
- *
171
- * Data structure conforming to the `PendingTransaction` interface specified by
172
- * `RelayMutationQueue`.
173
- */
174
-
175
-
176
- var PendingGraphQLTransaction =
177
- /*#__PURE__*/
178
- function () {
179
- // These properties required to conform to the PendingTransaction interface:
180
- // Other properties:
181
- function PendingGraphQLTransaction(environment, query, variables, files, optimisticQuery, optimisticResponse, collisionKey, callbacks) {
182
- this._configs = [];
183
- this._query = query;
184
- this._variables = variables;
185
- this._files = files;
186
- this._optimisticQuery = optimisticQuery || null;
187
- this._optimisticResponse = optimisticResponse || null;
188
- this._collisionKey = collisionKey;
189
- this.onFailure = callbacks && callbacks.onFailure;
190
- this.onSuccess = callbacks && callbacks.onSuccess;
191
- this.status = require("./RelayMutationTransactionStatus").CREATED;
192
- this.error = null;
193
- this._mutation = null;
194
- this._optimisticConfigs = null;
195
- this._optimisticMutation = null;
196
- this.mutationTransaction = environment.getStoreData().getMutationQueue().createTransactionWithPendingTransaction(this);
197
- this.id = this.mutationTransaction.getID();
198
- } // Methods from the PendingTransaction interface.
199
-
200
-
201
- var _proto2 = PendingGraphQLTransaction.prototype;
202
-
203
- _proto2.getCallName = function getCallName() {
204
- !this._mutation ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayGraphQLMutation: `getCallName()` called but no mutation exists ' + '(`getQuery()` must be called first to construct the mutation).') : require("fbjs/lib/invariant")(false) : void 0;
205
- return this._mutation.getCall().name;
206
- };
207
-
208
- _proto2.getCollisionKey = function getCollisionKey() {
209
- return this._collisionKey;
210
- };
211
-
212
- _proto2.getConfigs = function getConfigs() {
213
- return this._configs;
214
- };
215
-
216
- _proto2.getFiles = function getFiles() {
217
- return this._files;
218
- };
219
-
220
- _proto2.getOptimisticConfigs = function getOptimisticConfigs() {
221
- return this._optimisticConfigs;
222
- };
223
-
224
- _proto2.getOptimisticQuery = function getOptimisticQuery(storeData) {
225
- if (!this._optimisticMutation && this._optimisticQuery) {
226
- var concreteMutation = require("./QueryBuilder").getMutation(this._optimisticQuery);
227
-
228
- var mutation = require("./RelayQuery").Mutation.create(concreteMutation, require("./RelayMetaRoute").get('$RelayGraphQLMutation'), this._getVariables());
229
-
230
- this._optimisticMutation = mutation; // Cast RelayQuery.{Node -> Mutation}.
231
- }
232
-
233
- return this._optimisticMutation;
234
- };
235
-
236
- _proto2.getOptimisticResponse = function getOptimisticResponse() {
237
- return (0, _objectSpread4["default"])({}, this._optimisticResponse, (0, _defineProperty2["default"])({}, require("relay-runtime").ConnectionInterface.get().CLIENT_MUTATION_ID, this.id));
238
- };
239
-
240
- _proto2.getQuery = function getQuery(storeData) {
241
- if (!this._mutation) {
242
- var concreteMutation = require("./QueryBuilder").getMutation(this._query);
243
-
244
- var mutation = require("./RelayQuery").Mutation.create(concreteMutation, require("./RelayMetaRoute").get('$RelayGraphQLMutation'), this._getVariables());
245
-
246
- this._mutation = mutation; // Cast RelayQuery.{Node -> Mutation}.
247
- }
248
-
249
- return this._mutation;
250
- }; // Additional methods outside the PendingTransaction interface.
251
-
252
-
253
- _proto2.commit = function commit(configs) {
254
- if (configs) {
255
- this._configs = configs;
256
- }
257
-
258
- return this.mutationTransaction.commit();
259
- };
260
-
261
- _proto2.applyOptimistic = function applyOptimistic(configs) {
262
- if (configs) {
263
- this._optimisticConfigs = configs;
264
- }
265
-
266
- return this.mutationTransaction.applyOptimistic();
267
- };
268
-
269
- _proto2.rollback = function rollback() {
270
- this.mutationTransaction.rollback();
271
- };
272
-
273
- _proto2._getVariables = function _getVariables() {
274
- var input = this._variables.input;
275
-
276
- if (!input) {
277
- !false ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayGraphQLMutation: Required `input` variable is missing ' + '(supplied variables were: [%s]).', Object.keys(this._variables).join(', ')) : require("fbjs/lib/invariant")(false) : void 0;
278
- }
279
-
280
- return (0, _objectSpread4["default"])({}, this._variables, {
281
- input: (0, _objectSpread4["default"])({}, input, (0, _defineProperty2["default"])({}, require("relay-runtime").ConnectionInterface.get().CLIENT_MUTATION_ID, this.id))
282
- });
283
- };
284
-
285
- return PendingGraphQLTransaction;
286
- }();
287
-
288
- module.exports = RelayGraphQLMutation;
@@ -1,42 +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
- * Runtime function to correspond to the `graphql` tagged template function.
14
- * All calls to this function should be transformed by the plugin.
15
- */
16
- function graphql() {
17
- !false ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'graphql: Unexpected invocation at runtime. Either the Babel transform ' + 'was not set up, or it failed to identify this call site. Make sure it ' + 'is being used verbatim as `graphql`.') : require("fbjs/lib/invariant")(false) : void 0;
18
- }
19
-
20
- function isClassicFragment(taggedNode) {
21
- return require("./QueryBuilder").getFragmentDefinition(require("./RelayQL").__getClassicNode(taggedNode)) != null;
22
- }
23
-
24
- function isClassicOperation(taggedNode) {
25
- return require("./QueryBuilder").getOperationDefinition(require("./RelayQL").__getClassicNode(taggedNode)) != null;
26
- }
27
-
28
- function getClassicFragment(taggedNode) {
29
- return require("./RelayQL").__getClassicFragment(taggedNode);
30
- }
31
-
32
- function getClassicOperation(taggedNode) {
33
- return require("./RelayQL").__getClassicOperation(taggedNode);
34
- }
35
-
36
- module.exports = {
37
- getClassicFragment: getClassicFragment,
38
- getClassicOperation: getClassicOperation,
39
- graphql: graphql,
40
- isClassicFragment: isClassicFragment,
41
- isClassicOperation: isClassicOperation
42
- };
@@ -1,15 +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
- * @internal
13
- *
14
- * These are types shared across multiple files within Relay internals.
15
- */
@@ -1,24 +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
- * This module contains internal Relay modules that we expose for development
14
- * tools. They should be considered private APIs.
15
- *
16
- * @internal
17
- */
18
- var RelayInternals = {
19
- NetworkLayer: require("./RelayStore").getStoreData().getNetworkLayer(),
20
- DefaultStoreData: require("./RelayStore").getStoreData(),
21
- flattenRelayQuery: require("./flattenRelayQuery"),
22
- printRelayQuery: require("./printRelayQuery")
23
- };
24
- module.exports = RelayInternals;
@@ -1,35 +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
- * Meta route based on the real route; provides access to the route name in
13
- * queries.
14
- */
15
-
16
- var RelayMetaRoute =
17
- /*#__PURE__*/
18
- function () {
19
- function RelayMetaRoute(name) {
20
- Object.defineProperty(this, 'name', {
21
- enumerable: true,
22
- value: name,
23
- writable: false
24
- });
25
- }
26
-
27
- RelayMetaRoute.get = function get(name) {
28
- return cache[name] || (cache[name] = new RelayMetaRoute(name));
29
- };
30
-
31
- return RelayMetaRoute;
32
- }();
33
-
34
- var cache = {};
35
- module.exports = RelayMetaRoute;
@@ -1,71 +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
- var _assertThisInitialized2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/assertThisInitialized"));
15
-
16
- var _defineProperty2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/defineProperty"));
17
-
18
- /**
19
- * A helper for rendering RelayContainers with mock data, outside of a
20
- * RelayRootContainer/RelayRenderer. This is intended for use in unit tests or
21
- * component browser-style interfaces.
22
- *
23
- * Note: For unit tests, you may need to mock `ReactDOM` as follows:
24
- *
25
- * ```
26
- * jest.mock('ReactDOM', () => ({}));
27
- * ```
28
- *
29
- * Currently ReactDOM and ReactTestRenderer cannot both be loaded in the same
30
- * test, and Relay transitively includes ReactDOM under its default settings.
31
- */
32
- // this should be deprecated
33
- var RelayMockRenderer =
34
- /*#__PURE__*/
35
- function (_React$Component) {
36
- (0, _inheritsLoose2["default"])(RelayMockRenderer, _React$Component);
37
-
38
- function RelayMockRenderer() {
39
- var _this;
40
-
41
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
42
- args[_key] = arguments[_key];
43
- }
44
-
45
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
46
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])((0, _assertThisInitialized2["default"])(_this)), "mockContext", {
47
- environment: new (require("./RelayEnvironment"))(),
48
- variables: {},
49
- route: {
50
- name: '$RelayMockRenderer',
51
- params: {},
52
- queries: {},
53
- useMockData: true
54
- },
55
- useFakeData: true
56
- });
57
- return _this;
58
- }
59
-
60
- var _proto = RelayMockRenderer.prototype;
61
-
62
- _proto.render = function render() {
63
- return require("react").createElement(require("./ReactRelayContext").Provider, {
64
- value: this.mockContext
65
- }, this.props.render());
66
- };
67
-
68
- return RelayMockRenderer;
69
- }(require("react").Component);
70
-
71
- module.exports = RelayMockRenderer;