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,40 +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
- * @public
14
- *
15
- * Implementation of `RelayCore#createOperationDescriptor()` defined in
16
- * `RelayEnvironmentTypes` for the classic core.
17
- */
18
- function createOperationDescriptor(operation, variables) {
19
- var concreteFragment = require("./QueryBuilder").getFragment(operation.node);
20
-
21
- !concreteFragment ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayOperationDescriptor: Expected a query, got %s `%s`.', operation.node.kind, operation.name) : require("fbjs/lib/invariant")(false) : void 0;
22
-
23
- var operationVariables = require("./RelayVariables").getOperationVariables(operation, variables);
24
-
25
- var fragment = {
26
- dataID: require("./RelayStoreConstants").ROOT_ID,
27
- node: concreteFragment,
28
- variables: operationVariables
29
- };
30
- return {
31
- fragment: fragment,
32
- node: operation,
33
- root: fragment,
34
- variables: operationVariables
35
- };
36
- }
37
-
38
- module.exports = {
39
- createOperationDescriptor: createOperationDescriptor
40
- };
@@ -1,208 +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 ARGUMENTS = /^(\w+)(?:\((.+?)\))?$/;
17
- var ARGUMENT_NAME = /(\w+)(?=\s*:)/;
18
- var DEPRECATED_CALLS = /^\w+(?:\.\w+\(.*?\))+$/;
19
- var DEPRECATED_CALL = /^(\w+)\((.*?)\)$/;
20
-
21
- var idField = require("./RelayQuery").Field.build({
22
- fieldName: require("./RelayNodeInterface").ID,
23
- type: 'String'
24
- });
25
-
26
- var cursorField = require("./RelayQuery").Field.build({
27
- fieldName: 'cursor',
28
- type: 'String'
29
- });
30
- /**
31
- * @internal
32
- */
33
-
34
-
35
- var RelayOptimisticMutationUtils = {
36
- /**
37
- * Given a record-like object, infers fields that could be used to fetch them.
38
- * Properties that are fetched via fields with arguments can be encoded by
39
- * serializing the arguments in property keys.
40
- */
41
- inferRelayFieldsFromData: function inferRelayFieldsFromData(data) {
42
- var fields = [];
43
-
44
- require("fbjs/lib/forEachObject")(data, function (value, key) {
45
- if (!require("./RelayRecord").isMetadataKey(key)) {
46
- fields.push(inferField(value, key));
47
- }
48
- });
49
-
50
- return fields;
51
- },
52
-
53
- /**
54
- * Given a record-like object, infer the proper payload to be used to store
55
- * them. Properties that are fetched via fields with arguments will be
56
- * encoded by serializing the arguments in property keys.
57
- */
58
- inferRelayPayloadFromData: function inferRelayPayloadFromData(data) {
59
- var payload = data;
60
-
61
- require("fbjs/lib/forEachObject")(data, function (value, key) {
62
- if (!require("./RelayRecord").isMetadataKey(key)) {
63
- var _inferPayload = inferPayload(value, key),
64
- newValue = _inferPayload.newValue,
65
- newKey = _inferPayload.newKey;
66
-
67
- if (newKey !== key) {
68
- payload = (0, _objectSpread4["default"])({}, payload, (0, _defineProperty2["default"])({}, newKey, newValue));
69
- delete payload[key];
70
- } else if (newValue !== value) {
71
- payload = (0, _objectSpread4["default"])({}, payload, (0, _defineProperty2["default"])({}, key, newValue));
72
- }
73
- }
74
- });
75
-
76
- return payload;
77
- }
78
- };
79
-
80
- function inferField(value, key) {
81
- var _ConnectionInterface$ = require("relay-runtime").ConnectionInterface.get(),
82
- NODE = _ConnectionInterface$.NODE,
83
- EDGES = _ConnectionInterface$.EDGES;
84
-
85
- var metadata = {
86
- canHaveSubselections: true,
87
- isPlural: false
88
- };
89
- var children;
90
-
91
- if (Array.isArray(value)) {
92
- var element = value[0];
93
-
94
- if (element && typeof element === 'object') {
95
- children = RelayOptimisticMutationUtils.inferRelayFieldsFromData(element);
96
- } else {
97
- metadata.canHaveSubselections = false;
98
- children = [];
99
- }
100
-
101
- metadata.isPlural = true;
102
- } else if (typeof value === 'object' && value !== null) {
103
- children = RelayOptimisticMutationUtils.inferRelayFieldsFromData(value);
104
- } else {
105
- metadata.canHaveSubselections = false;
106
- children = [];
107
- }
108
-
109
- if (key === NODE) {
110
- children.push(idField);
111
- } else if (key === EDGES) {
112
- children.push(cursorField);
113
- }
114
-
115
- return buildField(key, children, metadata);
116
- }
117
-
118
- function inferPayload(value, key) {
119
- var metadata = {
120
- canHaveSubselections: true,
121
- isPlural: false
122
- };
123
- var newValue = value;
124
-
125
- if (Array.isArray(value) && Array.isArray(newValue)) {
126
- for (var ii = 0; ii < value.length; ii++) {
127
- var element = value[ii];
128
-
129
- if (element && typeof element === 'object') {
130
- var newElement = RelayOptimisticMutationUtils.inferRelayPayloadFromData(element);
131
-
132
- if (newElement !== element) {
133
- newValue = newValue.slice();
134
- newValue[ii] = newElement;
135
- }
136
- } else {
137
- metadata.canHaveSubselections = false;
138
- }
139
- }
140
-
141
- metadata.isPlural = true;
142
- } else if (typeof value === 'object' && value !== null) {
143
- newValue = RelayOptimisticMutationUtils.inferRelayPayloadFromData(value);
144
- } else {
145
- metadata.canHaveSubselections = false;
146
- }
147
-
148
- var field = buildField(key, [], metadata);
149
- return {
150
- newValue: newValue,
151
- newKey: field.getSerializationKey()
152
- };
153
- }
154
-
155
- function buildField(key, children, metadata) {
156
- var fieldName = key;
157
- var calls = null;
158
-
159
- if (DEPRECATED_CALLS.test(key)) {
160
- process.env.NODE_ENV !== "production" ? require("fbjs/lib/warning")(false, 'RelayOptimisticMutationUtils: Encountered an optimistic payload with ' + 'a deprecated field call string, `%s`. Use valid GraphQL OSS syntax.', key) : void 0;
161
- var parts = key.split('.');
162
-
163
- if (parts.length > 1) {
164
- fieldName = parts.shift();
165
- calls = parts.map(function (callString) {
166
- var captures = callString.match(DEPRECATED_CALL);
167
- !captures ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayOptimisticMutationUtils: Malformed data key, `%s`.', key) : require("fbjs/lib/invariant")(false) : void 0;
168
- var value = captures[2].split(',');
169
- return {
170
- name: captures[1],
171
- value: value.length === 1 ? value[0] : value
172
- };
173
- });
174
- }
175
- } else {
176
- var captures = key.match(ARGUMENTS);
177
- !captures ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayOptimisticMutationUtils: Malformed data key, `%s`.', key) : require("fbjs/lib/invariant")(false) : void 0;
178
- fieldName = captures[1];
179
-
180
- if (captures[2]) {
181
- try {
182
- // Relay does not currently have a GraphQL argument parser, so...
183
- var args = JSON.parse('{' + captures[2].replace(ARGUMENT_NAME, '"$1"') + '}');
184
- calls = Object.keys(args).map(function (name) {
185
- return {
186
- name: name,
187
- value: args[name]
188
- };
189
- });
190
- } catch (error) {
191
- !false ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayOptimisticMutationUtils: Malformed or unsupported data key, ' + '`%s`. Only booleans, strings, and numbers are currently supported, ' + 'and commas are required. Parse failure reason was `%s`.', key, error.message) : require("fbjs/lib/invariant")(false) : void 0;
192
- }
193
- }
194
- }
195
- /* $FlowFixMe - Flow error detected during the deployment of v0.38.0. To see
196
- * the error, remove this comment and run flow */
197
-
198
-
199
- return require("./RelayQuery").Field.build({
200
- calls: calls,
201
- children: children,
202
- fieldName: fieldName,
203
- metadata: metadata,
204
- type: require("./RelayNodeInterface").ANY_TYPE
205
- });
206
- }
207
-
208
- module.exports = RelayOptimisticMutationUtils;
@@ -1,166 +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
- * @internal
14
- *
15
- * Tracks pending (in-flight) queries.
16
- */
17
- var RelayPendingQueryTracker =
18
- /*#__PURE__*/
19
- function () {
20
- // Asynchronous mapping from preload query IDs to results.
21
- function RelayPendingQueryTracker(storeData) {
22
- this._pendingFetchMap = {};
23
- this._preloadQueryMap = new (require("fbjs/lib/PromiseMap"))();
24
- this._storeData = storeData;
25
- }
26
- /**
27
- * Used by `GraphQLQueryRunner` to enqueue new queries.
28
- */
29
-
30
-
31
- var _proto = RelayPendingQueryTracker.prototype;
32
-
33
- _proto.add = function add(params) {
34
- return new PendingFetch(params, {
35
- pendingFetchMap: this._pendingFetchMap,
36
- preloadQueryMap: this._preloadQueryMap,
37
- storeData: this._storeData
38
- });
39
- };
40
-
41
- _proto.hasPendingQueries = function hasPendingQueries() {
42
- return hasItems(this._pendingFetchMap);
43
- };
44
- /**
45
- * Clears all pending query tracking. Does not cancel the queries themselves.
46
- */
47
-
48
-
49
- _proto.resetPending = function resetPending() {
50
- this._pendingFetchMap = {};
51
- };
52
-
53
- _proto.resolvePreloadQuery = function resolvePreloadQuery(queryID, result) {
54
- this._preloadQueryMap.resolveKey(queryID, result);
55
- };
56
-
57
- _proto.rejectPreloadQuery = function rejectPreloadQuery(queryID, error) {
58
- this._preloadQueryMap.rejectKey(queryID, error);
59
- };
60
-
61
- return RelayPendingQueryTracker;
62
- }();
63
- /**
64
- * @private
65
- */
66
-
67
-
68
- var PendingFetch =
69
- /*#__PURE__*/
70
- function () {
71
- function PendingFetch(_ref, _ref2) {
72
- var fetchMode = _ref.fetchMode,
73
- forceIndex = _ref.forceIndex,
74
- query = _ref.query;
75
- var pendingFetchMap = _ref2.pendingFetchMap,
76
- preloadQueryMap = _ref2.preloadQueryMap,
77
- storeData = _ref2.storeData;
78
- var queryID = query.getID();
79
- this._forceIndex = forceIndex;
80
- this._pendingFetchMap = pendingFetchMap;
81
- this._preloadQueryMap = preloadQueryMap;
82
- this._query = query;
83
- this._resolvedDeferred = new (require("fbjs/lib/Deferred"))();
84
- this._resolvedQuery = false;
85
- this._storeData = storeData;
86
- this._fetchQueryPromise = fetchMode === require("./RelayFetchMode").PRELOAD ? this._preloadQueryMap.get(queryID) : storeData.getNetworkLayer().fetchRelayQuery(query);
87
- this._fetchedQuery = false;
88
- this._error = null;
89
- this._pendingFetchMap[queryID] = {
90
- fetch: this,
91
- query: query
92
- };
93
-
94
- require("./throwFailedPromise")(this._fetchQueryPromise.then(this._handleQuerySuccess.bind(this), this._handleQueryFailure.bind(this)));
95
- }
96
-
97
- var _proto2 = PendingFetch.prototype;
98
-
99
- _proto2.isResolvable = function isResolvable() {
100
- return this._resolvedQuery;
101
- };
102
-
103
- _proto2.getQuery = function getQuery() {
104
- return this._query;
105
- };
106
-
107
- _proto2.getResolvedPromise = function getResolvedPromise() {
108
- return this._resolvedDeferred.getPromise();
109
- };
110
-
111
- _proto2._handleQuerySuccess = function _handleQuerySuccess(result) {
112
- var _this = this;
113
-
114
- this._fetchedQuery = true;
115
-
116
- require("./throwFailedPromise")(this._storeData.getTaskQueue().enqueue(function () {
117
- var response = result.response;
118
- !(response && typeof response === 'object') ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayPendingQueryTracker: Expected response to be an object, got ' + '`%s`.', response ? typeof response : response) : require("fbjs/lib/invariant")(false) : void 0;
119
-
120
- _this._storeData.handleQueryPayload(_this._query, response, _this._forceIndex);
121
- }).then(this._markQueryAsResolved.bind(this), this._markAsRejected.bind(this)));
122
- };
123
-
124
- _proto2._handleQueryFailure = function _handleQueryFailure(error) {
125
- this._markAsRejected(error);
126
- };
127
-
128
- _proto2._markQueryAsResolved = function _markQueryAsResolved() {
129
- var queryID = this.getQuery().getID();
130
- delete this._pendingFetchMap[queryID];
131
- this._resolvedQuery = true;
132
-
133
- this._updateResolvedDeferred();
134
- };
135
-
136
- _proto2._markAsRejected = function _markAsRejected(error) {
137
- var queryID = this.getQuery().getID();
138
- delete this._pendingFetchMap[queryID];
139
- console.warn(error.message);
140
- this._error = error;
141
-
142
- this._updateResolvedDeferred();
143
- };
144
-
145
- _proto2._updateResolvedDeferred = function _updateResolvedDeferred() {
146
- if (this._isSettled() && !this._resolvedDeferred.isSettled()) {
147
- if (this._error) {
148
- this._resolvedDeferred.reject(this._error);
149
- } else {
150
- this._resolvedDeferred.resolve(undefined);
151
- }
152
- }
153
- };
154
-
155
- _proto2._isSettled = function _isSettled() {
156
- return !!this._error || this._resolvedQuery;
157
- };
158
-
159
- return PendingFetch;
160
- }();
161
-
162
- function hasItems(map) {
163
- return !!Object.keys(map).length;
164
- }
165
-
166
- module.exports = RelayPendingQueryTracker;
@@ -1,57 +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 RelayPropTypes = {
13
- Container: function Container(props, propName, componentName) {
14
- var component = props[propName];
15
-
16
- if (component == null) {
17
- return new Error(require("fbjs/lib/sprintf")('Required prop `%s` was not specified in `%s`.', propName, componentName));
18
- } else if (!require("./isRelayContainer")(component)) {
19
- return new Error(require("fbjs/lib/sprintf")('Invalid prop `%s` supplied to `%s`, expected a RelayContainer.', propName, componentName));
20
- }
21
-
22
- return null;
23
- },
24
- Environment: function Environment(props, propName, componentName) {
25
- var context = props[propName];
26
-
27
- if (!require("./isClassicRelayEnvironment")(context) || !require("./isRelayEnvironment")(context)) {
28
- return new Error(require("fbjs/lib/sprintf")('Invalid prop/context `%s` supplied to `%s`, expected `%s` to be ' + 'an object conforming to the `RelayEnvironment` interface.', propName, componentName, context));
29
- }
30
-
31
- return null;
32
- },
33
- QueryConfig: require("prop-types").shape({
34
- name: require("prop-types").string.isRequired,
35
- params: require("prop-types").object.isRequired,
36
- queries: require("prop-types").object.isRequired
37
- }),
38
- ClassicRelay: function ClassicRelay(props, propName, componentName) {
39
- var relay = props[propName];
40
-
41
- if (!require("./RelayContext").isRelayContext(relay) || !require("./isClassicRelayEnvironment")(relay.environment)) {
42
- return new Error(require("fbjs/lib/sprintf")('Invalid prop/context `%s` supplied to `%s`, expected `%s` to be ' + 'an object with a classic `environment` implementation and `variables`.', propName, componentName, relay));
43
- }
44
-
45
- return null;
46
- },
47
- Relay: function Relay(props, propName, componentName) {
48
- var relay = props[propName];
49
-
50
- if (!require("./RelayContext").isRelayContext(relay)) {
51
- return new Error(require("fbjs/lib/sprintf")('Invalid prop/context `%s` supplied to `%s`, expected `%s` to be ' + 'an object with an `environment` and `variables`.', propName, componentName, relay));
52
- }
53
-
54
- return null;
55
- }
56
- };
57
- module.exports = RelayPropTypes;
@@ -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
- if (typeof global.__REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined') {
13
- global.__REACT_DEVTOOLS_GLOBAL_HOOK__._relayInternals = require("./RelayInternals");
14
- }
15
- /**
16
- * Relay contains the set of public methods used to initialize and orchestrate
17
- * a React application that uses GraphQL to declare data dependencies.
18
- */
19
-
20
-
21
- var RelayPublic = {
22
- Environment: require("./RelayEnvironment"),
23
- GraphQLMutation: require("./RelayGraphQLMutation"),
24
- GraphQLStoreQueryResolver: require("./GraphQLStoreQueryResolver"),
25
- Mutation: require("./RelayMutation"),
26
- PropTypes: require("./RelayPropTypes"),
27
- QL: require("./RelayQL"),
28
- QueryConfig: require("./RelayQueryConfig"),
29
- ReadyStateRenderer: require("./RelayReadyStateRenderer"),
30
- RelayContainerProxy: require("./RelayContainerProxy"),
31
- Renderer: require("./RelayRenderer"),
32
- RootContainer: require("./RelayRootContainer"),
33
- Route: require("./RelayRoute"),
34
- Store: require("./RelayStore"),
35
- MutationTypes: require("relay-runtime").MutationTypes,
36
- RangeOperations: require("relay-runtime").RangeOperations,
37
- createContainer: require("./RelayContainer").create,
38
- createQuery: require("./createRelayQuery"),
39
- getQueries: require("./getRelayQueries"),
40
- injectNetworkLayer: require("./RelayStore").injectNetworkLayer.bind(require("./RelayStore")),
41
- injectTaskScheduler: require("./RelayStore").injectTaskScheduler.bind(require("./RelayStore")),
42
- isContainer: require("./isRelayContainer")
43
- };
44
- module.exports = RelayPublic;
package/lib/RelayQL.js DELETED
@@ -1,128 +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
- * This is a tag function used with template strings to provide the facade of a
18
- * runtime GraphQL parser. Example usage:
19
- *
20
- * Relay.QL`fragment on User { name }`
21
- *
22
- * In actuality, a Babel transform parses these tag templates and replaces it
23
- * with an internal representation of the query structure.
24
- */
25
- function RelayQL(strings) {
26
- !false ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayQL: 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 `Relay.QL`.') : require("fbjs/lib/invariant")(false) : void 0;
27
- }
28
-
29
- function assertValidFragment(substitution) {
30
- !(substitution instanceof require("./RelayFragmentReference") || require("./QueryBuilder").getFragment(substitution) || require("./QueryBuilder").getFragmentSpread(substitution)) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayQL: Invalid fragment composition, use ' + "`${Child.getFragment('name')}`.") : require("fbjs/lib/invariant")(false) : void 0;
31
- }
32
-
33
- var CLASSIC_NODE = '__classic_node__';
34
- /**
35
- * Private helper methods used by the transformed code.
36
- */
37
-
38
- Object.assign(RelayQL, {
39
- __frag: function __frag(substitution) {
40
- if (typeof substitution === 'function') {
41
- // Route conditional fragment, e.g. `${route => matchRoute(route, ...)}`.
42
- return new (require("./RelayRouteFragment"))(substitution);
43
- }
44
-
45
- if (substitution != null) {
46
- if (Array.isArray(substitution)) {
47
- substitution.forEach(assertValidFragment);
48
- } else {
49
- assertValidFragment(substitution);
50
- }
51
- }
52
-
53
- return substitution;
54
- },
55
- __var: function __var(expression) {
56
- var variable = require("./QueryBuilder").getCallVariable(expression);
57
-
58
- if (variable) {
59
- !false ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayQL: Invalid argument `%s` supplied via template substitution. ' + 'Instead, use an inline variable (e.g. `comments(count: $count)`).', variable.callVariableName) : require("fbjs/lib/invariant")(false) : void 0;
60
- }
61
-
62
- return require("./QueryBuilder").createCallValue(expression);
63
- },
64
- __id: function __id() {
65
- return require("./generateConcreteFragmentID")();
66
- },
67
- __createFragment: function __createFragment(fragment, variableMapping) {
68
- return new (require("./RelayFragmentReference"))(function () {
69
- return fragment;
70
- }, null, variableMapping);
71
- },
72
-
73
- /**
74
- * Memoizes the results of executing the `.classic()` functions on
75
- * graphql`...` tagged expressions. Memoization allows the framework to use
76
- * object equality checks to compare fragments (useful, for example, when
77
- * comparing two `Selector`s to see if they select the same data).
78
- */
79
- __getClassicNode: function __getClassicNode(taggedNode) {
80
- var concreteNode = taggedNode[CLASSIC_NODE];
81
-
82
- if (concreteNode == null) {
83
- var fn = taggedNode.classic;
84
- !(typeof fn === 'function') ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayQL: Expected a graphql literal, got `%s`.\n' + 'The "relay" Babel plugin must enable "compat" mode to be used with ' + '"react-relay/compat" or "react-relay/classic".\n' + 'See: https://facebook.github.io/relay/docs/babel-plugin-relay.html', JSON.stringify(taggedNode)) : require("fbjs/lib/invariant")(false) : void 0;
85
- concreteNode = fn(this);
86
- taggedNode[CLASSIC_NODE] = concreteNode;
87
- }
88
-
89
- return concreteNode;
90
- },
91
- __getClassicFragment: function __getClassicFragment(taggedNode, isUnMasked) {
92
- var concreteNode = this.__getClassicNode(taggedNode);
93
-
94
- var fragment = require("./QueryBuilder").getFragmentDefinition(concreteNode);
95
-
96
- !fragment ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayQL: Expected a fragment, got `%s`.\n' + 'The "relay" Babel plugin must enable "compat" mode to be used with ' + '"react-relay/compat" or "react-relay/classic".\n' + 'See: https://facebook.github.io/relay/docs/babel-plugin-relay.html', concreteNode) : require("fbjs/lib/invariant")(false) : void 0;
97
-
98
- if (isUnMasked) {
99
- /*
100
- * For a regular `Fragment` or `Field` node, its variables have been declared
101
- * in the parent. However, since unmasked fragment is actually parsed as `FragmentSpread`,
102
- * we need to manually hoist its arguments to the parent.
103
- * In reality, we do not actually hoist the arguments because Babel transform is per file.
104
- * Instead, we could put the `argumentDefinitions` in the `metadata` and resolve the variables
105
- * when building the concrete fragment node.
106
- */
107
- var hoistedRootArgs = [];
108
- fragment.argumentDefinitions.forEach(function (argDef) {
109
- !(argDef.kind === 'RootArgument') ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayQL: Cannot unmask fragment `%s`. Expected all the arguments are root argument' + ' but get `%s`', concreteNode.node.name, argDef.name) : require("fbjs/lib/invariant")(false) : void 0;
110
- hoistedRootArgs.push(argDef.name);
111
- });
112
- fragment.node.metadata = (0, _objectSpread2["default"])({}, concreteNode.node.metadata, {
113
- hoistedRootArgs: hoistedRootArgs
114
- });
115
- }
116
-
117
- return fragment;
118
- },
119
- __getClassicOperation: function __getClassicOperation(taggedNode) {
120
- var concreteNode = this.__getClassicNode(taggedNode);
121
-
122
- var operation = require("./QueryBuilder").getOperationDefinition(concreteNode);
123
-
124
- !operation ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayQL: Expected an operation, got `%s`.\n' + 'The "relay" Babel plugin must enable "compat" mode to be used with ' + '"react-relay/compat" or "react-relay/classic".\n' + 'See: https://facebook.github.io/relay/docs/babel-plugin-relay.html', concreteNode) : require("fbjs/lib/invariant")(false) : void 0;
125
- return operation;
126
- }
127
- });
128
- module.exports = RelayQL;