relay-runtime 1.7.0-rc.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/LICENSE +1 -1
  2. package/index.js +1 -1
  3. package/lib/ConvertToExecuteFunction.js +12 -75
  4. package/lib/DataChecker.js +400 -0
  5. package/lib/NormalizationNode.js +14 -0
  6. package/lib/ReaderNode.js +10 -0
  7. package/lib/RelayCombinedEnvironmentTypes.js +10 -0
  8. package/lib/RelayConcreteNode.js +12 -29
  9. package/lib/RelayConcreteVariables.js +17 -11
  10. package/lib/RelayConnectionHandler.js +98 -42
  11. package/lib/RelayConnectionInterface.js +5 -13
  12. package/lib/RelayCore.js +17 -14
  13. package/lib/RelayDeclarativeMutationConfig.js +69 -34
  14. package/lib/RelayDefaultHandleKey.js +1 -2
  15. package/lib/RelayDefaultHandlerProvider.js +6 -5
  16. package/lib/RelayError.js +6 -9
  17. package/lib/RelayInMemoryRecordSource.js +20 -22
  18. package/lib/RelayModernEnvironment.js +140 -229
  19. package/lib/RelayModernFragmentSpecResolver.js +110 -102
  20. package/lib/RelayModernGraphQLTag.js +53 -15
  21. package/lib/{RelayModernOperationSelector.js → RelayModernOperationDescriptor.js} +9 -8
  22. package/lib/RelayModernQueryExecutor.js +172 -0
  23. package/lib/RelayModernRecord.js +97 -38
  24. package/lib/RelayModernSelector.js +89 -33
  25. package/lib/RelayModernStore.js +301 -0
  26. package/lib/RelayNetwork.js +16 -28
  27. package/lib/RelayNetworkLogger.js +2 -3
  28. package/lib/RelayNetworkLoggerTransaction.js +32 -30
  29. package/lib/RelayNetworkTypes.js +1 -2
  30. package/lib/RelayObservable.js +127 -155
  31. package/lib/RelayProfiler.js +35 -22
  32. package/lib/RelayPublishQueue.js +144 -96
  33. package/lib/RelayQueryResponseCache.js +37 -21
  34. package/lib/RelayReader.js +194 -61
  35. package/lib/RelayRecordProxy.js +50 -31
  36. package/lib/RelayRecordSourceMutator.js +92 -51
  37. package/lib/RelayRecordSourceProxy.js +43 -35
  38. package/lib/RelayRecordSourceSelectorProxy.js +22 -21
  39. package/lib/RelayRecordState.js +1 -3
  40. package/lib/RelayReferenceMarker.js +110 -37
  41. package/lib/RelayResponseNormalizer.js +248 -82
  42. package/lib/RelayRuntimeTypes.js +1 -3
  43. package/lib/RelayStoreTypes.js +1 -2
  44. package/lib/RelayStoreUtils.js +37 -19
  45. package/lib/RelayViewerHandler.js +14 -10
  46. package/lib/applyRelayModernOptimisticMutation.js +8 -8
  47. package/lib/cloneRelayHandleSourceField.js +8 -9
  48. package/lib/commitLocalUpdate.js +1 -2
  49. package/lib/commitRelayModernMutation.js +21 -14
  50. package/lib/createRelayNetworkLogger.js +11 -9
  51. package/lib/deepFreeze.js +2 -3
  52. package/lib/fetchRelayModernQuery.js +10 -12
  53. package/lib/generateRelayClientID.js +4 -2
  54. package/lib/getRelayHandleKey.js +5 -6
  55. package/lib/hasOverlappingIDs.js +3 -2
  56. package/lib/index.js +59 -62
  57. package/lib/isPromise.js +1 -2
  58. package/lib/isRelayModernEnvironment.js +1 -3
  59. package/lib/isScalarAndEqual.js +1 -3
  60. package/lib/normalizePayload.js +17 -15
  61. package/lib/normalizeRelayPayload.js +9 -9
  62. package/lib/recycleNodesInto.js +25 -9
  63. package/lib/requestRelaySubscription.js +25 -58
  64. package/lib/simpleClone.js +2 -3
  65. package/lib/stableCopy.js +5 -3
  66. package/lib/validateMutation.js +146 -0
  67. package/package.json +3 -3
  68. package/relay-runtime.js +4 -0
  69. package/relay-runtime.min.js +9 -0
  70. package/lib/RelayDataLoader.js +0 -302
  71. package/lib/RelayMarkSweepStore.js +0 -242
  72. package/lib/deferrableFragmentKey.js +0 -20
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2013-present, Facebook, Inc.
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -7,14 +7,11 @@
7
7
  *
8
8
  * @format
9
9
  */
10
-
11
10
  'use strict';
12
11
 
13
- var _classCallCheck3 = _interopRequireDefault(require('babel-runtime/helpers/classCallCheck'));
14
-
15
- var _toConsumableArray3 = _interopRequireDefault(require('babel-runtime/helpers/toConsumableArray'));
12
+ var _defineProperty2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/defineProperty"));
16
13
 
17
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
14
+ var _toConsumableArray2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/toConsumableArray"));
18
15
 
19
16
  var queryID = 1;
20
17
 
@@ -25,16 +22,16 @@ var queryID = 1;
25
22
  * `console.log`. Another might ping a logging endpoint. Another might add some
26
23
  * autogenerated logs before doing either of the foregoing.
27
24
  */
28
- var RelayNetworkLoggerTransaction = function () {
25
+ var RelayNetworkLoggerTransaction =
26
+ /*#__PURE__*/
27
+ function () {
29
28
  function RelayNetworkLoggerTransaction(_ref) {
30
29
  var request = _ref.request,
31
30
  variables = _ref.variables,
32
31
  cacheConfig = _ref.cacheConfig,
33
32
  uploadables = _ref.uploadables;
34
- (0, _classCallCheck3['default'])(this, RelayNetworkLoggerTransaction);
35
- this._hasCommittedLogs = false;
36
- this._logs = [];
37
-
33
+ (0, _defineProperty2["default"])(this, "_hasCommittedLogs", false);
34
+ (0, _defineProperty2["default"])(this, "_logs", []);
38
35
  this._cacheConfig = cacheConfig;
39
36
  this._id = queryID++;
40
37
  this._request = request;
@@ -42,22 +39,27 @@ var RelayNetworkLoggerTransaction = function () {
42
39
  this._variables = variables;
43
40
  }
44
41
 
45
- RelayNetworkLoggerTransaction.prototype.addLog = function addLog(label) {
46
- for (var _len = arguments.length, values = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
42
+ var _proto = RelayNetworkLoggerTransaction.prototype;
43
+
44
+ _proto.addLog = function addLog(label) {
45
+ for (var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
47
46
  values[_key - 1] = arguments[_key];
48
47
  }
49
48
 
50
- this._logs.push({ label: label, values: values });
49
+ this._logs.push({
50
+ label: label,
51
+ values: values
52
+ });
51
53
  };
52
54
 
53
- RelayNetworkLoggerTransaction.prototype.clearLogs = function clearLogs() {
55
+ _proto.clearLogs = function clearLogs() {
54
56
  this._logs = [];
55
57
  };
56
58
 
57
- RelayNetworkLoggerTransaction.prototype.printLogs = function printLogs(error, payload, status) {
59
+ _proto.printLogs = function printLogs(error, payload, status) {
58
60
  /* eslint-disable no-console */
59
61
  var transactionId = this.getIdentifier();
60
- console.groupCollapsed && console.groupCollapsed('%c' + transactionId, error ? 'color:red' : '');
62
+ console.groupCollapsed && console.groupCollapsed("%c".concat(transactionId), error ? 'color:red' : '');
61
63
  console.timeEnd && console.timeEnd(transactionId);
62
64
  this.getLogsToPrint(error, payload, status).forEach(function (_ref2) {
63
65
  var _console;
@@ -65,49 +67,49 @@ var RelayNetworkLoggerTransaction = function () {
65
67
  var label = _ref2.label,
66
68
  values = _ref2.values;
67
69
 
68
- (_console = console).log.apply(_console, [label + ':'].concat((0, _toConsumableArray3['default'])(values)));
70
+ (_console = console).log.apply(_console, ["".concat(label, ":")].concat((0, _toConsumableArray2["default"])(values)));
69
71
  });
70
72
  console.groupEnd && console.groupEnd();
71
73
  /* eslint-enable no-console */
72
74
  };
73
75
 
74
- RelayNetworkLoggerTransaction.prototype.commitLogs = function commitLogs(error, payload, status) {
75
- !(this._hasCommittedLogs === false) ? process.env.NODE_ENV !== 'production' ? require('fbjs/lib/invariant')(false, 'The logs for transaction #' + this._id + ' have already been committed.') : require('fbjs/lib/invariant')(false) : void 0;
76
+ _proto.commitLogs = function commitLogs(error, payload, status) {
77
+ !(this._hasCommittedLogs === false) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, "The logs for transaction #".concat(this._id, " have already been committed.")) : require("fbjs/lib/invariant")(false) : void 0;
76
78
  this.printLogs(error, payload, status);
77
79
  this.markCommitted();
78
80
  };
79
81
 
80
- RelayNetworkLoggerTransaction.prototype.markCommitted = function markCommitted() {
82
+ _proto.markCommitted = function markCommitted() {
81
83
  this._hasCommittedLogs = true;
82
84
  };
83
85
 
84
- RelayNetworkLoggerTransaction.prototype.flushLogs = function flushLogs(error, payload, status) {
85
- !(this._hasCommittedLogs === false) ? process.env.NODE_ENV !== 'production' ? require('fbjs/lib/invariant')(false, 'The logs for transaction #' + this._id + ' have already been committed.') : require('fbjs/lib/invariant')(false) : void 0;
86
+ _proto.flushLogs = function flushLogs(error, payload, status) {
87
+ !(this._hasCommittedLogs === false) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, "The logs for transaction #".concat(this._id, " have already been committed.")) : require("fbjs/lib/invariant")(false) : void 0;
86
88
  this.printLogs(error, payload, status);
87
89
  this.clearLogs();
88
90
  };
89
91
 
90
- RelayNetworkLoggerTransaction.prototype.getCacheConfig = function getCacheConfig() {
92
+ _proto.getCacheConfig = function getCacheConfig() {
91
93
  return this._cacheConfig;
92
94
  };
93
95
 
94
- RelayNetworkLoggerTransaction.prototype.getIdentifier = function getIdentifier() {
95
- return '[' + this._id + '] Relay Modern: ' + this._request.name;
96
+ _proto.getIdentifier = function getIdentifier() {
97
+ return "[".concat(this._id, "] Relay Modern: ").concat(this._request.name);
96
98
  };
97
99
 
98
- RelayNetworkLoggerTransaction.prototype.getLogsToPrint = function getLogsToPrint(error, payload, status) {
100
+ _proto.getLogsToPrint = function getLogsToPrint(error, payload, status) {
99
101
  return this._logs;
100
102
  };
101
103
 
102
- RelayNetworkLoggerTransaction.prototype.getRequest = function getRequest() {
104
+ _proto.getRequest = function getRequest() {
103
105
  return this._request;
104
106
  };
105
107
 
106
- RelayNetworkLoggerTransaction.prototype.getUploadables = function getUploadables() {
108
+ _proto.getUploadables = function getUploadables() {
107
109
  return this._uploadables;
108
110
  };
109
111
 
110
- RelayNetworkLoggerTransaction.prototype.getVariables = function getVariables() {
112
+ _proto.getVariables = function getVariables() {
111
113
  return this._variables;
112
114
  };
113
115
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2013-present, Facebook, Inc.
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -7,5 +7,4 @@
7
7
  * strict-local
8
8
  * @format
9
9
  */
10
-
11
10
  'use strict';