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,201 +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
- /**
15
- * @public
16
- */
17
- function getSelector(operationVariables, fragment, item) {
18
- !(typeof item === 'object' && item !== null && !Array.isArray(item)) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelaySelector: Expected value for fragment `%s` to be an object, got ' + '`%s`.', fragment.node.name, JSON.stringify(item)) : require("fbjs/lib/invariant")(false) : void 0;
19
-
20
- var dataID = require("./RelayRecord").getDataIDForObject(item);
21
-
22
- var fragmentVariables = require("./RelayFragmentPointer").getVariablesForID(item, fragment.node.id);
23
-
24
- if (dataID != null && fragmentVariables != null) {
25
- return {
26
- dataID: dataID,
27
- node: fragment.node,
28
- variables: (0, _objectSpread2["default"])({}, operationVariables, fragmentVariables)
29
- };
30
- }
31
-
32
- process.env.NODE_ENV !== "production" ? require("fbjs/lib/warning")(false, 'RelaySelector: Expected object to contain data for fragment `%s`, got ' + '`%s`. Make sure that the parent operation/fragment included fragment ' + '`...%s`.', fragment.node.name, JSON.stringify(item), fragment.node.name) : void 0;
33
- return null;
34
- }
35
- /**
36
- * @public
37
- */
38
-
39
-
40
- function getSelectorList(operationVariables, fragment, items) {
41
- var selectors = null;
42
- items.forEach(function (item) {
43
- var selector = item != null ? getSelector(operationVariables, fragment, item) : null;
44
-
45
- if (selector != null) {
46
- selectors = selectors || [];
47
- selectors.push(selector);
48
- }
49
- });
50
- return selectors;
51
- }
52
- /**
53
- * @public
54
- */
55
-
56
-
57
- function getSelectorsFromObject(operationVariables, fragments, object) {
58
- var selectors = {};
59
-
60
- require("fbjs/lib/forEachObject")(fragments, function (fragment, key) {
61
- var item = object[key];
62
-
63
- if (item == null) {
64
- selectors[key] = item;
65
- } else if (fragment.node.metadata && fragment.node.metadata.plural === true) {
66
- !Array.isArray(item) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelaySelector: Expected value for key `%s` to be an array, got `%s`. ' + 'Remove `@relay(plural: true)` from fragment `%s` to allow the prop to be an object.', key, JSON.stringify(item), fragment.node.name) : require("fbjs/lib/invariant")(false) : void 0;
67
- selectors[key] = getSelectorList(operationVariables, fragment, item);
68
- } else {
69
- !!Array.isArray(item) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelaySelector: Expected value for key `%s` to be an object, got `%s`. ' + 'Add `@relay(plural: true)` to fragment `%s` to allow the prop to be an array of items.', key, JSON.stringify(item), fragment.node.name) : require("fbjs/lib/invariant")(false) : void 0;
70
- selectors[key] = getSelector(operationVariables, fragment, item);
71
- }
72
- });
73
-
74
- return selectors;
75
- }
76
- /**
77
- * @public
78
- *
79
- * Given a mapping of keys -> results and a mapping of keys -> fragments,
80
- * extracts a mapping of keys -> id(s) of the results.
81
- *
82
- * Similar to `getSelectorsFromObject()`, this function can be useful in
83
- * determining the "identity" of the props passed to a component.
84
- */
85
-
86
-
87
- function getDataIDsFromObject(fragments, object) {
88
- var ids = {};
89
-
90
- require("fbjs/lib/forEachObject")(fragments, function (fragment, key) {
91
- var item = object[key];
92
-
93
- if (item == null) {
94
- ids[key] = item;
95
- } else if (fragment.node.metadata && fragment.node.metadata.plural === true) {
96
- !Array.isArray(item) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelaySelector: Expected value for key `%s` to be an array, got `%s`. ' + 'Remove `@relay(plural: true)` from fragment `%s` to allow the prop to be an object.', key, JSON.stringify(item), fragment.node.name) : require("fbjs/lib/invariant")(false) : void 0;
97
- ids[key] = getDataIDs(fragment, item);
98
- } else {
99
- !!Array.isArray(item) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelaySelector: Expected value for key `%s` to be an object, got `%s`. ' + 'Add `@relay(plural: true)` to fragment `%s` to allow the prop to be an array of items.', key, JSON.stringify(item), fragment.node.name) : require("fbjs/lib/invariant")(false) : void 0;
100
- ids[key] = getDataID(fragment, item);
101
- }
102
- });
103
-
104
- return ids;
105
- }
106
- /**
107
- * @internal
108
- */
109
-
110
-
111
- function getDataIDs(fragment, items) {
112
- var ids;
113
- items.forEach(function (item) {
114
- var id = item != null ? getDataID(fragment, item) : null;
115
-
116
- if (id != null) {
117
- ids = ids || [];
118
- ids.push(id);
119
- }
120
- });
121
- return ids || null;
122
- }
123
- /**
124
- * @internal
125
- */
126
-
127
-
128
- function getDataID(fragment, item) {
129
- !(typeof item === 'object' && item !== null && !Array.isArray(item)) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelaySelector: Expected value for fragment `%s` to be an object, got ' + '`%s`.', fragment.node.name, JSON.stringify(item)) : require("fbjs/lib/invariant")(false) : void 0;
130
-
131
- var dataID = require("./RelayRecord").getDataIDForObject(item);
132
-
133
- if (dataID != null) {
134
- return dataID;
135
- }
136
-
137
- process.env.NODE_ENV !== "production" ? require("fbjs/lib/warning")(false, 'RelaySelector: Expected object to contain data for fragment `%s`, got ' + '`%s`. Make sure that the parent operation/fragment included fragment ' + '`...%s`.', fragment.node.name, JSON.stringify(item), fragment.node.name) : void 0;
138
- return null;
139
- }
140
- /**
141
- * @public
142
- */
143
-
144
-
145
- function getVariablesFromObject(operationVariables, fragments, object) {
146
- var variables = {};
147
-
148
- require("fbjs/lib/forEachObject")(fragments, function (fragment, key) {
149
- var item = object[key];
150
-
151
- if (item == null) {
152
- return;
153
- } else if (fragment.node.metadata && fragment.node.metadata.plural === true) {
154
- !Array.isArray(item) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelaySelector: Expected value for key `%s` to be an array, got `%s`. ' + 'Remove `@relay(plural: true)` from fragment `%s` to allow the prop to be an object.', key, JSON.stringify(item), fragment.node.name) : require("fbjs/lib/invariant")(false) : void 0;
155
- item.forEach(function (value) {
156
- if (value != null) {
157
- var itemVariables = getVariables(operationVariables, fragment, value);
158
-
159
- if (itemVariables) {
160
- Object.assign(variables, itemVariables);
161
- }
162
- }
163
- });
164
- } else {
165
- !!Array.isArray(item) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelaySelector: Expected value for key `%s` to be an object, got `%s`. ' + 'Add `@relay(plural: true)` to fragment `%s` to allow the prop to be an array of items.', key, JSON.stringify(item), fragment.node.name) : require("fbjs/lib/invariant")(false) : void 0;
166
- var itemVariables = getVariables(operationVariables, fragment, item);
167
-
168
- if (itemVariables) {
169
- Object.assign(variables, itemVariables);
170
- }
171
- }
172
- });
173
-
174
- return variables;
175
- }
176
- /**
177
- * @internal
178
- */
179
-
180
-
181
- function getVariables(operationVariables, fragment, item) {
182
- var selector = getSelector(operationVariables, fragment, item);
183
- return selector ? selector.variables : null;
184
- }
185
- /**
186
- * @public
187
- */
188
-
189
-
190
- function areEqualSelectors(thisSelector, thatSelector) {
191
- return thisSelector.dataID === thatSelector.dataID && thisSelector.node === thatSelector.node && require("fbjs/lib/areEqual")(thisSelector.variables, thatSelector.variables);
192
- }
193
-
194
- module.exports = {
195
- areEqualSelectors: areEqualSelectors,
196
- getDataIDsFromObject: getDataIDsFromObject,
197
- getSelector: getSelector,
198
- getSelectorList: getSelectorList,
199
- getSelectorsFromObject: getSelectorsFromObject,
200
- getVariablesFromObject: getVariablesFromObject
201
- };
@@ -1,69 +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
-
11
- /**
12
- * @description
13
- * RelayShallowMock allows testing Relay components in isolation.
14
- * Every Relay container will only render the name of the component it contains.
15
- * Adds `unwrap` to the container that returns the component to test.
16
- *
17
- * @example
18
- * jest.mock('Relay', () => require('./RelayShallowMock'));
19
- * const renderer = require('ReactTestRenderer');
20
- * const MyContainer = require('MyContainer');
21
- *
22
- * test('the wrapped component', () => {
23
- * const MyComponent = MyContainer.unwrap();
24
- * // Here I can test the component by passing the properties I want to test
25
- * // any containers inside the component will render as:
26
- * // <RelayContainer>Component Name</RelayContainer>
27
- * expect(
28
- * renderer.create(
29
- * <MyComponent myProp={{}} myOtherProp={{}} />
30
- * ).toMatchSnapshot()
31
- * );
32
- * });
33
- *
34
- */
35
- 'use strict';
36
-
37
- var _objectSpread2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/objectSpread"));
38
-
39
- var _inheritsLoose2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/inheritsLoose"));
40
-
41
- var Relay = require.requireActual("./RelayPublic");
42
-
43
- var RelayShallowMock = {
44
- createContainer: function createContainer(component, spec) {
45
- return (
46
- /*#__PURE__*/
47
- function (_React$Component) {
48
- (0, _inheritsLoose2["default"])(_class, _React$Component);
49
-
50
- function _class() {
51
- return _React$Component.apply(this, arguments) || this;
52
- }
53
-
54
- var _proto = _class.prototype;
55
-
56
- _proto.render = function render() {
57
- return require("react").createElement("Relay(".concat(component.displayName || component.name || 'Unknown', ")"));
58
- };
59
-
60
- _class.unwrap = function unwrap() {
61
- return component;
62
- };
63
-
64
- return _class;
65
- }(require("react").Component)
66
- );
67
- }
68
- };
69
- module.exports = (0, _objectSpread2["default"])({}, Relay, RelayShallowMock);
@@ -1,38 +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
- * @typechecks
8
- *
9
- * @format
10
- */
11
- 'use strict';
12
-
13
- var _inheritsLoose2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/inheritsLoose"));
14
-
15
- var RelayStaticContainer =
16
- /*#__PURE__*/
17
- function (_React$Component) {
18
- (0, _inheritsLoose2["default"])(RelayStaticContainer, _React$Component);
19
-
20
- function RelayStaticContainer() {
21
- return _React$Component.apply(this, arguments) || this;
22
- }
23
-
24
- var _proto = RelayStaticContainer.prototype;
25
-
26
- _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
27
- return !!nextProps.shouldUpdate;
28
- };
29
-
30
- _proto.render = function render() {
31
- var child = this.props.children;
32
- return child ? require("react").Children.only(child) : null;
33
- };
34
-
35
- return RelayStaticContainer;
36
- }(require("react").Component);
37
-
38
- module.exports = RelayStaticContainer;
package/lib/RelayStore.js DELETED
@@ -1,12 +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
- module.exports = new (require("./RelayEnvironment"))();
@@ -1,20 +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
- * An id used for the root of the graph, corresponding to the "Query" type.
13
- * Conceptually, root fields in queries can be viewed as normal fields on a
14
- * synthesized root record.
15
- */
16
-
17
- var ROOT_ID = 'client:root';
18
- module.exports = {
19
- ROOT_ID: ROOT_ID
20
- };