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,268 +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 _objectSpread2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/objectSpread"));
13
-
14
- var _inheritsLoose2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/inheritsLoose"));
15
-
16
- var _assertThisInitialized2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/assertThisInitialized"));
17
-
18
- var _defineProperty2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/defineProperty"));
19
-
20
- var INACTIVE_READY_STATE = {
21
- aborted: false,
22
- done: false,
23
- error: null,
24
- events: [],
25
- ready: false,
26
- stale: false
27
- };
28
- /**
29
- * @public
30
- *
31
- * RelayRenderer renders a container and query config after fulfilling its data
32
- * dependencies. Precise rendering behavior is configured via the `render` prop
33
- * which takes a callback.
34
- *
35
- * The container created using `Relay.createContainer` must be supplied via the
36
- * `Container` prop, and the query configuration that conforms to the shape of a
37
- * `RelayQueryConfig` must be supplied via the `queryConfig` prop.
38
- *
39
- * === Render Callback ===
40
- *
41
- * The `render` callback is called with an object with the following properties:
42
- *
43
- * props: ?{[propName: string]: mixed}
44
- * If present, sufficient data is ready to render the container. This object
45
- * must be spread into the container using the spread attribute operator. If
46
- * absent, there is insufficient data to render the container.
47
- *
48
- * done: boolean
49
- * Whether all data dependencies have been fulfilled. If `props` is present
50
- * but `done` is false, then sufficient data is ready to render, but some
51
- * data dependencies have not yet been fulfilled.
52
- *
53
- * error: ?Error
54
- * If present, an error occurred while fulfilling data dependencies. If
55
- * `props` and `error` are both present, then sufficient data is ready to
56
- * render, but an error occurred while fulfilling deferred dependencies.
57
- *
58
- * retry: ?Function
59
- * A function that can be called to re-attempt to fulfill data dependencies.
60
- * This property is only present if an `error` has occurred.
61
- *
62
- * stale: boolean
63
- * When `forceFetch` is enabled, a request is always made to fetch updated
64
- * data. However, if all data dependencies can be immediately fulfilled, the
65
- * `props` property will be present. In this case, `stale` will be true.
66
- *
67
- * The `render` callback can return `undefined` to continue rendering the last
68
- * view rendered (e.g. when transitioning from one `queryConfig` to another).
69
- *
70
- * If a `render` callback is not supplied, the default behavior is to render the
71
- * container if data is available, the existing view if one exists, or nothing.
72
- *
73
- * === Refs ===
74
- *
75
- * References to elements rendered by the `render` callback can be obtained by
76
- * using the React `ref` prop. For example:
77
- *
78
- * <FooComponent {...props} ref={handleFooRef} />
79
- *
80
- * function handleFooRef(component) {
81
- * // Invoked when `<FooComponent>` is mounted or unmounted. When mounted,
82
- * // `component` will be the component. When unmounted, `component` will
83
- * // be null.
84
- * }
85
- *
86
- */
87
-
88
- var RelayRenderer =
89
- /*#__PURE__*/
90
- function (_React$Component) {
91
- (0, _inheritsLoose2["default"])(RelayRenderer, _React$Component);
92
-
93
- function RelayRenderer(props, context) {
94
- var _this;
95
-
96
- _this = _React$Component.call(this, props, context) || this;
97
- _this.mounted = true;
98
- _this.pendingRequest = null;
99
- _this.state = {
100
- active: false,
101
- readyState: null,
102
- retry: _this._retry.bind((0, _assertThisInitialized2["default"])((0, _assertThisInitialized2["default"])(_this)))
103
- };
104
- return _this;
105
- }
106
-
107
- var _proto = RelayRenderer.prototype;
108
-
109
- _proto.componentDidMount = function componentDidMount() {
110
- this._validateProps(this.props);
111
-
112
- this._runQueries(this.props);
113
- };
114
- /**
115
- * @private
116
- */
117
-
118
-
119
- _proto._validateProps = function _validateProps(props) {
120
- var error = RelayRenderer.propTypes.Container(props, 'Container', 'RelayRenderer');
121
-
122
- if (error) {
123
- throw error;
124
- }
125
- };
126
- /**
127
- * @private
128
- */
129
-
130
-
131
- _proto._runQueries = function _runQueries(_ref) {
132
- var _this2 = this;
133
-
134
- var Container = _ref.Container,
135
- forceFetch = _ref.forceFetch,
136
- onForceFetch = _ref.onForceFetch,
137
- onPrimeCache = _ref.onPrimeCache,
138
- queryConfig = _ref.queryConfig,
139
- environment = _ref.environment,
140
- shouldFetch = _ref.shouldFetch;
141
-
142
- if (!shouldFetch) {
143
- return;
144
- }
145
-
146
- var onReadyStateChange = function onReadyStateChange(readyState) {
147
- if (!_this2.mounted) {
148
- _this2._handleReadyStateChange((0, _objectSpread2["default"])({}, readyState, {
149
- mounted: false
150
- }));
151
-
152
- return;
153
- }
154
-
155
- if (request !== _this2.lastRequest) {
156
- // Ignore (abort) ready state if we have a new pending request.
157
- return;
158
- }
159
-
160
- if (readyState.aborted || readyState.done || readyState.error) {
161
- _this2.pendingRequest = null;
162
- }
163
-
164
- _this2.setState({
165
- active: true,
166
- readyState: (0, _objectSpread2["default"])({}, readyState, {
167
- mounted: true
168
- })
169
- });
170
- };
171
-
172
- if (this.pendingRequest) {
173
- this.pendingRequest.abort();
174
- }
175
-
176
- var querySet = require("./getRelayQueries")(Container, queryConfig);
177
-
178
- var request = this.pendingRequest = forceFetch ? onForceFetch ? onForceFetch(querySet, onReadyStateChange) : environment.forceFetch(querySet, onReadyStateChange) : onPrimeCache ? onPrimeCache(querySet, onReadyStateChange) : environment.primeCache(querySet, onReadyStateChange);
179
- this.lastRequest = request;
180
- };
181
- /**
182
- * @private
183
- */
184
-
185
-
186
- _proto._retry = function _retry() {
187
- var readyState = this.state.readyState;
188
-
189
- if (readyState && readyState.error) {
190
- this._runQueries(this.props);
191
-
192
- this.setState({
193
- readyState: null
194
- });
195
- }
196
- };
197
-
198
- _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
199
- if (nextProps.Container !== this.props.Container || nextProps.environment !== this.props.environment || nextProps.queryConfig !== this.props.queryConfig || nextProps.shouldFetch !== this.props.shouldFetch || nextProps.forceFetch && !this.props.forceFetch) {
200
- this._validateProps(nextProps);
201
-
202
- this._runQueries(nextProps);
203
-
204
- this.setState({
205
- readyState: null
206
- });
207
- }
208
- };
209
-
210
- _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
211
- // `prevState` should exist; the truthy check is for Flow soundness.
212
- var readyState = this.state.readyState;
213
-
214
- if (readyState) {
215
- if (!prevState || readyState !== prevState.readyState) {
216
- this._handleReadyStateChange(readyState);
217
- }
218
- }
219
- };
220
- /**
221
- * @private
222
- */
223
-
224
-
225
- _proto._handleReadyStateChange = function _handleReadyStateChange(readyState) {
226
- var onReadyStateChange = this.props.onReadyStateChange;
227
-
228
- if (onReadyStateChange) {
229
- onReadyStateChange(readyState);
230
- }
231
- };
232
-
233
- _proto.componentWillUnmount = function componentWillUnmount() {
234
- if (this.pendingRequest) {
235
- this.pendingRequest.abort();
236
- }
237
-
238
- this.mounted = false;
239
- };
240
-
241
- _proto.render = function render() {
242
- var readyState = this.state.active ? this.state.readyState : INACTIVE_READY_STATE;
243
- return require("react").createElement(require("./RelayReadyStateRenderer"), {
244
- Container: this.props.Container,
245
- environment: this.props.environment,
246
- queryConfig: this.props.queryConfig,
247
- readyState: readyState,
248
- render: this.props.render,
249
- retry: this.state.retry
250
- });
251
- };
252
-
253
- return RelayRenderer;
254
- }(require("react").Component);
255
-
256
- (0, _defineProperty2["default"])(RelayRenderer, "propTypes", {
257
- Container: require("./RelayPropTypes").Container,
258
- forceFetch: require("prop-types").bool,
259
- onReadyStateChange: require("prop-types").func,
260
- queryConfig: require("./RelayPropTypes").QueryConfig.isRequired,
261
- environment: require("./RelayPropTypes").Environment,
262
- render: require("prop-types").func,
263
- shouldFetch: require("prop-types").bool
264
- });
265
- (0, _defineProperty2["default"])(RelayRenderer, "defaultProps", {
266
- shouldFetch: true
267
- });
268
- module.exports = RelayRenderer;
@@ -1,125 +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
- /**
13
- * @public
14
- *
15
- * RelayRootContainer sends requests for data required to render the supplied
16
- * `Component` and `route`. The `Component` must be a container created using
17
- * `Relay.createContainer`.
18
- *
19
- * === Render Callbacks ===
20
- *
21
- * Whenever the RelayRootContainer renders, one of three render callback props
22
- * are invoked depending on whether data is being loaded, can be resolved, or if
23
- * an error is incurred.
24
- *
25
- * ReactDOM.render(
26
- * <RelayRootContainer
27
- * Component={FooComponent}
28
- * route={fooRoute}
29
- * renderLoading={function() {
30
- * return <View>Loading...</View>;
31
- * }}
32
- * renderFetched={function(data) {
33
- * // Must spread `data` into <FooComponent>.
34
- * return <FooComponent {...data} />;
35
- * }}
36
- * renderFailure={function(error) {
37
- * return <View>Error: {error.message}</View>;
38
- * }}
39
- * />,
40
- * ...
41
- * );
42
- *
43
- * If a callback is not supplied, it has a default behavior:
44
- *
45
- * - Without `renderFetched`, `Component` will be rendered with fetched data.
46
- * - Without `renderFailure`, an error will render to null.
47
- * - Without `renderLoading`, the existing view will continue to render. If
48
- * this is the initial mount (with no existing view), renders to null.
49
- *
50
- * In addition, supplying a `renderLoading` that returns undefined has the same
51
- * effect as not supplying the callback. (Usually, an undefined return value is
52
- * an error in React).
53
- *
54
- * === Refs ===
55
- *
56
- * References to elements rendered by any of these callbacks can be obtained by
57
- * using the React `ref` prop. For example:
58
- *
59
- * <FooComponent {...data} ref={handleFooRef} />
60
- *
61
- * function handleFooRef(component) {
62
- * // Invoked when `<FooComponent>` is mounted or unmounted. When mounted,
63
- * // `component` will be the component. When unmounted, `component` will
64
- * // be null.
65
- * }
66
- *
67
- */
68
- function RelayRootContainer(_ref) {
69
- var Component = _ref.Component,
70
- forceFetch = _ref.forceFetch,
71
- onReadyStateChange = _ref.onReadyStateChange,
72
- renderFailure = _ref.renderFailure,
73
- renderFetched = _ref.renderFetched,
74
- renderLoading = _ref.renderLoading,
75
- route = _ref.route,
76
- shouldFetch = _ref.shouldFetch;
77
- return require("react").createElement(require("./RelayRenderer"), {
78
- Container: Component,
79
- forceFetch: forceFetch,
80
- onReadyStateChange: onReadyStateChange,
81
- queryConfig: route,
82
- environment: require("./RelayStore"),
83
- shouldFetch: shouldFetch,
84
- render: function render(_ref2) {
85
- var done = _ref2.done,
86
- error = _ref2.error,
87
- props = _ref2.props,
88
- retry = _ref2.retry,
89
- stale = _ref2.stale;
90
-
91
- if (error) {
92
- if (renderFailure) {
93
- return renderFailure(error, retry);
94
- }
95
- } else if (props) {
96
- if (renderFetched) {
97
- return renderFetched(props, {
98
- done: done,
99
- stale: stale
100
- });
101
- } else {
102
- return require("react").createElement(Component, props);
103
- }
104
- } else {
105
- if (renderLoading) {
106
- return renderLoading();
107
- }
108
- }
109
-
110
- return undefined;
111
- }
112
- });
113
- }
114
-
115
- RelayRootContainer.propTypes = {
116
- Component: require("./RelayPropTypes").Container,
117
- forceFetch: require("prop-types").bool,
118
- onReadyStateChange: require("prop-types").func,
119
- renderFailure: require("prop-types").func,
120
- renderFetched: require("prop-types").func,
121
- renderLoading: require("prop-types").func,
122
- route: require("./RelayPropTypes").QueryConfig.isRequired,
123
- shouldFetch: require("prop-types").bool
124
- };
125
- module.exports = RelayRootContainer;
package/lib/RelayRoute.js DELETED
@@ -1,92 +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 createURI = function createURI() {
17
- return null;
18
- };
19
- /**
20
- * Describes the root queries, param definitions and other metadata for a given
21
- * path (URI).
22
- */
23
-
24
-
25
- var RelayRoute =
26
- /*#__PURE__*/
27
- function (_RelayQueryConfig) {
28
- (0, _inheritsLoose2["default"])(RelayRoute, _RelayQueryConfig);
29
-
30
- function RelayRoute(initialVariables, uri) {
31
- var _this;
32
-
33
- _this = _RelayQueryConfig.call(this, initialVariables) || this;
34
- var constructor = _this.constructor;
35
- var routeName = constructor.routeName,
36
- path = constructor.path;
37
- !(constructor !== RelayRoute) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayRoute: Abstract class cannot be instantiated.') : require("fbjs/lib/invariant")(false) : void 0;
38
- !routeName ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, '%s: Subclasses of RelayRoute must define a `routeName`.', constructor.name || '<<anonymous>>') : require("fbjs/lib/invariant")(false) : void 0; // $FlowIssue #9905535 - Object.defineProperty doesn't understand getters
39
-
40
- Object.defineProperty((0, _assertThisInitialized2["default"])((0, _assertThisInitialized2["default"])(_this)), 'uri', {
41
- enumerable: true,
42
- get: function get() {
43
- if (!uri && path) {
44
- uri = createURI(constructor, this.params);
45
- }
46
-
47
- return uri;
48
- }
49
- });
50
- return _this;
51
- }
52
-
53
- var _proto = RelayRoute.prototype;
54
-
55
- _proto.prepareVariables = function prepareVariables(prevVariables) {
56
- var _this$constructor = this.constructor,
57
- paramDefinitions = _this$constructor.paramDefinitions,
58
- prepareParams = _this$constructor.prepareParams,
59
- routeName = _this$constructor.routeName;
60
- var params = prevVariables;
61
-
62
- if (prepareParams) {
63
- /* $FlowFixMe(>=0.17.0) - params is ?Tv but prepareParams expects Tv */
64
- params = prepareParams(params);
65
- }
66
-
67
- if (paramDefinitions) {
68
- require("fbjs/lib/forEachObject")(paramDefinitions, function (paramDefinition, paramName) {
69
- if (params) {
70
- if (params.hasOwnProperty(paramName)) {
71
- return;
72
- } else {
73
- // Backfill param so that a call variable is created for it.
74
- params[paramName] = undefined;
75
- }
76
- }
77
-
78
- !!paramDefinition.required ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayRoute: Missing required parameter `%s` in `%s`. Check the ' + 'supplied params or URI.', paramName, routeName) : require("fbjs/lib/invariant")(false) : void 0;
79
- });
80
- }
81
-
82
- return params;
83
- };
84
-
85
- RelayRoute.injectURICreator = function injectURICreator(creator) {
86
- createURI = creator;
87
- };
88
-
89
- return RelayRoute;
90
- }(require("./RelayQueryConfig"));
91
-
92
- module.exports = RelayRoute;
@@ -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
- * strict-local
8
- * @format
9
- */
10
- 'use strict';
11
-
12
- /**
13
- * Represents a query fragment that is conditional upon the active route as a
14
- * function that returns either a literal fragment or a fragment reference.
15
- *
16
- * Example GraphQL:
17
- *
18
- * ```
19
- * Node {
20
- * ${(route) => matchRoute(route, ...)}
21
- * }
22
- * ```
23
- */
24
- var RelayRouteFragment =
25
- /*#__PURE__*/
26
- function () {
27
- function RelayRouteFragment(builder) {
28
- this._builder = builder;
29
- }
30
- /**
31
- * Returns the query fragment that matches the given route, if any.
32
- */
33
-
34
-
35
- var _proto = RelayRouteFragment.prototype;
36
-
37
- _proto.getFragmentForRoute = function getFragmentForRoute(route) {
38
- return this._builder(route);
39
- };
40
-
41
- return RelayRouteFragment;
42
- }();
43
-
44
- module.exports = RelayRouteFragment;