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,82 +1,102 @@
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.
6
6
  *
7
7
  *
8
8
  * @format
9
+ * @emails oncall+relay
9
10
  */
10
-
11
11
  'use strict';
12
12
 
13
- var _classCallCheck3 = _interopRequireDefault(require('babel-runtime/helpers/classCallCheck'));
14
-
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
16
-
17
- var RelayModernEnvironment = function () {
13
+ var RelayModernEnvironment =
14
+ /*#__PURE__*/
15
+ function () {
18
16
  function RelayModernEnvironment(config) {
19
17
  var _this = this;
20
18
 
21
- (0, _classCallCheck3['default'])(this, RelayModernEnvironment);
22
- this._deferrableSelections = new Set();
23
-
24
19
  this.configName = config.configName;
25
- var handlerProvider = config.handlerProvider ? config.handlerProvider : require('./RelayDefaultHandlerProvider');
20
+ var handlerProvider = config.handlerProvider ? config.handlerProvider : require("./RelayDefaultHandlerProvider");
21
+ var operationLoader = config.operationLoader;
22
+
23
+ if (process.env.NODE_ENV !== "production") {
24
+ if (operationLoader != null) {
25
+ !(typeof operationLoader === 'object' && typeof operationLoader.get === 'function' && typeof operationLoader.load === 'function') ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayModernEnvironment: Expected `operationLoader` to be an object ' + 'with get() and load() functions, got `%s`.', operationLoader) : require("fbjs/lib/invariant")(false) : void 0;
26
+ }
27
+ }
28
+
29
+ this._operationLoader = operationLoader;
26
30
  this._network = config.network;
27
- this._publishQueue = new (require('./RelayPublishQueue'))(config.store, handlerProvider);
31
+ this._publishQueue = new (require("./RelayPublishQueue"))(config.store, handlerProvider);
28
32
  this._store = config.store;
29
- this.unstable_internal = require('./RelayCore');
33
+ this.unstable_internal = require("./RelayCore");
30
34
 
31
35
  this.__setNet = function (newNet) {
32
36
  return _this._network = newNet;
33
- };
34
-
35
- // Register this Relay Environment with Relay DevTools if it exists.
37
+ }; // Register this Relay Environment with Relay DevTools if it exists.
36
38
  // Note: this must always be the last step in the constructor.
39
+
40
+
37
41
  var _global = typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : undefined;
42
+
38
43
  var devToolsHook = _global && _global.__RELAY_DEVTOOLS_HOOK__;
44
+
39
45
  if (devToolsHook) {
40
46
  devToolsHook.registerEnvironment(this);
41
47
  }
48
+
49
+ if (config.missingFieldHandlers != null) {
50
+ this._missingFieldHandlers = config.missingFieldHandlers;
51
+ }
42
52
  }
43
53
 
44
- RelayModernEnvironment.prototype.getStore = function getStore() {
54
+ var _proto = RelayModernEnvironment.prototype;
55
+
56
+ _proto.getStore = function getStore() {
45
57
  return this._store;
46
58
  };
47
59
 
48
- RelayModernEnvironment.prototype.getNetwork = function getNetwork() {
60
+ _proto.getNetwork = function getNetwork() {
49
61
  return this._network;
50
62
  };
51
63
 
52
- RelayModernEnvironment.prototype.applyUpdate = function applyUpdate(optimisticUpdate) {
64
+ _proto.applyUpdate = function applyUpdate(optimisticUpdate) {
53
65
  var _this2 = this;
54
66
 
55
67
  var dispose = function dispose() {
56
68
  _this2._publishQueue.revertUpdate(optimisticUpdate);
69
+
57
70
  _this2._publishQueue.run();
58
71
  };
72
+
59
73
  this._publishQueue.applyUpdate(optimisticUpdate);
74
+
60
75
  this._publishQueue.run();
61
- return { dispose: dispose };
76
+
77
+ return {
78
+ dispose: dispose
79
+ };
62
80
  };
63
81
 
64
- RelayModernEnvironment.prototype.revertUpdate = function revertUpdate(update) {
82
+ _proto.revertUpdate = function revertUpdate(update) {
65
83
  this._publishQueue.revertUpdate(update);
84
+
66
85
  this._publishQueue.run();
67
86
  };
68
87
 
69
- RelayModernEnvironment.prototype.replaceUpdate = function replaceUpdate(update, newUpdate) {
88
+ _proto.replaceUpdate = function replaceUpdate(update, newUpdate) {
70
89
  this._publishQueue.revertUpdate(update);
90
+
71
91
  this._publishQueue.applyUpdate(newUpdate);
92
+
72
93
  this._publishQueue.run();
73
94
  };
74
95
 
75
- RelayModernEnvironment.prototype.applyMutation = function applyMutation(_ref) {
96
+ _proto.applyMutation = function applyMutation(_ref) {
76
97
  var operation = _ref.operation,
77
98
  optimisticResponse = _ref.optimisticResponse,
78
99
  optimisticUpdater = _ref.optimisticUpdater;
79
-
80
100
  return this.applyUpdate({
81
101
  operation: operation,
82
102
  selectorStoreUpdater: optimisticUpdater,
@@ -84,40 +104,56 @@ var RelayModernEnvironment = function () {
84
104
  });
85
105
  };
86
106
 
87
- RelayModernEnvironment.prototype.check = function check(readSelector) {
88
- return this._store.check(readSelector);
107
+ _proto.check = function check(readSelector) {
108
+ if (this._missingFieldHandlers == null) {
109
+ return this._store.check(readSelector);
110
+ }
111
+
112
+ return this._checkSelectorAndHandleMissingFields(readSelector, this._missingFieldHandlers);
89
113
  };
90
114
 
91
- RelayModernEnvironment.prototype.commitPayload = function commitPayload(operationSelector, payload) {
115
+ _proto.commitPayload = function commitPayload(operationDescriptor, payload) {
92
116
  // Do not handle stripped nulls when commiting a payload
93
- var relayPayload = require('./normalizeRelayPayload')(operationSelector.root, payload);
94
- this._publishQueue.commitPayload(operationSelector, relayPayload);
117
+ var relayPayload = require("./normalizeRelayPayload")(operationDescriptor.root, payload);
118
+
119
+ this._publishQueue.commitPayload(operationDescriptor, relayPayload);
120
+
95
121
  this._publishQueue.run();
96
122
  };
97
123
 
98
- RelayModernEnvironment.prototype.commitUpdate = function commitUpdate(updater) {
124
+ _proto.commitUpdate = function commitUpdate(updater) {
99
125
  this._publishQueue.commitUpdate(updater);
126
+
100
127
  this._publishQueue.run();
101
128
  };
102
129
 
103
- RelayModernEnvironment.prototype.lookup = function lookup(readSelector) {
104
- return this._store.lookup(readSelector);
130
+ _proto.lookup = function lookup(readSelector, owner) {
131
+ return this._store.lookup(readSelector, owner);
105
132
  };
106
133
 
107
- RelayModernEnvironment.prototype.subscribe = function subscribe(snapshot, callback) {
134
+ _proto.subscribe = function subscribe(snapshot, callback) {
108
135
  return this._store.subscribe(snapshot, callback);
109
136
  };
110
137
 
111
- RelayModernEnvironment.prototype.retain = function retain(selector) {
138
+ _proto.retain = function retain(selector) {
112
139
  return this._store.retain(selector);
113
140
  };
114
141
 
115
- RelayModernEnvironment.prototype.isSelectorLoading = function isSelectorLoading(selector) {
116
- var key = require('./deferrableFragmentKey')(selector.dataID, selector.node.name, selector.variables);
117
- return this._deferrableSelections.has(key);
142
+ _proto._checkSelectorAndHandleMissingFields = function _checkSelectorAndHandleMissingFields(selector, handlers) {
143
+ var target = new (require("./RelayInMemoryRecordSource"))();
144
+
145
+ var result = require("./DataChecker").check(this._store.getSource(), target, selector, handlers, this._operationLoader);
146
+
147
+ if (target.size() > 0) {
148
+ this._publishQueue.commitSource(target);
149
+
150
+ this._publishQueue.run();
151
+ }
152
+
153
+ return result;
118
154
  };
119
155
  /**
120
- * Returns an Observable of ExecutePayload resulting from executing the
156
+ * Returns an Observable of GraphQLResponse resulting from executing the
121
157
  * provided Query or Subscription operation, each result of which is then
122
158
  * normalized and committed to the publish queue.
123
159
  *
@@ -126,159 +162,21 @@ var RelayModernEnvironment = function () {
126
162
  */
127
163
 
128
164
 
129
- RelayModernEnvironment.prototype.execute = function execute(_ref2) {
130
- var _this3 = this;
131
-
165
+ _proto.execute = function execute(_ref2) {
132
166
  var operation = _ref2.operation,
133
167
  cacheConfig = _ref2.cacheConfig,
134
168
  updater = _ref2.updater;
135
-
136
- var optimisticResponse = void 0;
137
- return this._network.execute(operation.node, operation.variables, cacheConfig || {})['do']({
138
- next: function next(executePayload) {
139
- var responsePayload = require('./normalizePayload')(executePayload);
140
- var source = responsePayload.source,
141
- fieldPayloads = responsePayload.fieldPayloads,
142
- deferrableSelections = responsePayload.deferrableSelections;
143
- var _iteratorNormalCompletion = true;
144
- var _didIteratorError = false;
145
- var _iteratorError = undefined;
146
-
147
- try {
148
- for (var _iterator = (deferrableSelections || new Set())[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
149
- var selectionKey = _step.value;
150
-
151
- _this3._deferrableSelections.add(selectionKey);
152
- }
153
- } catch (err) {
154
- _didIteratorError = true;
155
- _iteratorError = err;
156
- } finally {
157
- try {
158
- if (!_iteratorNormalCompletion && _iterator['return']) {
159
- _iterator['return']();
160
- }
161
- } finally {
162
- if (_didIteratorError) {
163
- throw _iteratorError;
164
- }
165
- }
166
- }
167
-
168
- if (executePayload.isOptimistic) {
169
- !(optimisticResponse == null) ? process.env.NODE_ENV !== 'production' ? require('fbjs/lib/invariant')(false, 'environment.execute: only support one optimistic respnose per ' + 'execute.') : require('fbjs/lib/invariant')(false) : void 0;
170
- optimisticResponse = {
171
- source: source,
172
- fieldPayloads: fieldPayloads
173
- };
174
- _this3._publishQueue.applyUpdate(optimisticResponse);
175
- _this3._publishQueue.run();
176
- } else {
177
- if (optimisticResponse) {
178
- _this3._publishQueue.revertUpdate(optimisticResponse);
179
- optimisticResponse = undefined;
180
- }
181
- var writeSelector = require('./RelayModernOperationSelector').createOperationSelector(operation.node, executePayload.variables, executePayload.operation);
182
- if (executePayload.operation.kind === 'DeferrableOperation') {
183
- var fragmentKey = require('./deferrableFragmentKey')(executePayload.variables[executePayload.operation.rootFieldVariable], executePayload.operation.fragmentName, require('./RelayConcreteVariables').getOperationVariables(executePayload.operation, executePayload.variables));
184
- _this3._deferrableSelections['delete'](fragmentKey);
185
- }
186
- _this3._publishQueue.commitPayload(writeSelector, responsePayload, updater);
187
- _this3._publishQueue.run();
188
- }
189
- }
190
- })['finally'](function () {
191
- if (optimisticResponse) {
192
- _this3._publishQueue.revertUpdate(optimisticResponse);
193
- optimisticResponse = undefined;
194
- _this3._publishQueue.run();
195
- }
196
- });
197
- };
198
-
199
- /**
200
- * Returns an Observable of StreamPayload. Similar to .execute({...}),
201
- * except the stream can also return events, which is especially useful when
202
- * executing a GraphQL subscription. However, events are not commited to
203
- * the publish queue, they are simply ignored in the .do({...}) stream.
204
- */
205
-
206
-
207
- RelayModernEnvironment.prototype.executeWithEvents = function executeWithEvents(_ref3) {
208
- var _this4 = this;
209
-
210
- var operation = _ref3.operation,
211
- cacheConfig = _ref3.cacheConfig,
212
- updater = _ref3.updater;
213
-
214
- var optimisticResponse = void 0;
215
- return this._network.executeWithEvents(operation.node, operation.variables, cacheConfig || {})['do']({
216
- next: function next(executePayload) {
217
- if (executePayload.kind !== 'data') {
218
- return;
219
- }
220
- var responsePayload = require('./normalizePayload')(executePayload);
221
- var source = responsePayload.source,
222
- fieldPayloads = responsePayload.fieldPayloads,
223
- deferrableSelections = responsePayload.deferrableSelections;
224
- var _iteratorNormalCompletion2 = true;
225
- var _didIteratorError2 = false;
226
- var _iteratorError2 = undefined;
227
-
228
- try {
229
- for (var _iterator2 = (deferrableSelections || new Set())[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
230
- var selectionKey = _step2.value;
231
-
232
- _this4._deferrableSelections.add(selectionKey);
233
- }
234
- } catch (err) {
235
- _didIteratorError2 = true;
236
- _iteratorError2 = err;
237
- } finally {
238
- try {
239
- if (!_iteratorNormalCompletion2 && _iterator2['return']) {
240
- _iterator2['return']();
241
- }
242
- } finally {
243
- if (_didIteratorError2) {
244
- throw _iteratorError2;
245
- }
246
- }
247
- }
248
-
249
- if (executePayload.isOptimistic) {
250
- !(optimisticResponse == null) ? process.env.NODE_ENV !== 'production' ? require('fbjs/lib/invariant')(false, 'environment.execute: only support one optimistic respnose per ' + 'execute.') : require('fbjs/lib/invariant')(false) : void 0;
251
- optimisticResponse = {
252
- source: source,
253
- fieldPayloads: fieldPayloads
254
- };
255
- _this4._publishQueue.applyUpdate(optimisticResponse);
256
- _this4._publishQueue.run();
257
- } else {
258
- if (optimisticResponse) {
259
- _this4._publishQueue.revertUpdate(optimisticResponse);
260
- optimisticResponse = undefined;
261
- }
262
- var writeSelector = require('./RelayModernOperationSelector').createOperationSelector(operation.node, executePayload.variables, executePayload.operation);
263
- if (executePayload.operation.kind === 'DeferrableOperation') {
264
- var fragmentKey = require('./deferrableFragmentKey')(executePayload.variables[executePayload.operation.rootFieldVariable], executePayload.operation.fragmentName, require('./RelayConcreteVariables').getOperationVariables(executePayload.operation, executePayload.variables));
265
- _this4._deferrableSelections['delete'](fragmentKey);
266
- }
267
- _this4._publishQueue.commitPayload(writeSelector, responsePayload, updater);
268
- _this4._publishQueue.run();
269
- }
270
- }
271
- })['finally'](function () {
272
- if (optimisticResponse) {
273
- _this4._publishQueue.revertUpdate(optimisticResponse);
274
- optimisticResponse = undefined;
275
- _this4._publishQueue.run();
276
- }
169
+ return require("./RelayModernQueryExecutor").execute({
170
+ operation: operation,
171
+ cacheConfig: cacheConfig,
172
+ updater: updater,
173
+ network: this._network,
174
+ operationLoader: this._operationLoader,
175
+ publishQueue: this._publishQueue
277
176
  });
278
177
  };
279
-
280
178
  /**
281
- * Returns an Observable of ExecutePayload resulting from executing the
179
+ * Returns an Observable of GraphQLResponse resulting from executing the
282
180
  * provided Mutation operation, the result of which is then normalized and
283
181
  * committed to the publish queue along with an optional optimistic response
284
182
  * or updater.
@@ -289,16 +187,16 @@ var RelayModernEnvironment = function () {
289
187
  */
290
188
 
291
189
 
292
- RelayModernEnvironment.prototype.executeMutation = function executeMutation(_ref4) {
293
- var _this5 = this;
190
+ _proto.executeMutation = function executeMutation(_ref3) {
191
+ var _this3 = this;
294
192
 
295
- var operation = _ref4.operation,
296
- optimisticResponse = _ref4.optimisticResponse,
297
- optimisticUpdater = _ref4.optimisticUpdater,
298
- updater = _ref4.updater,
299
- uploadables = _ref4.uploadables;
193
+ var operation = _ref3.operation,
194
+ optimisticResponse = _ref3.optimisticResponse,
195
+ optimisticUpdater = _ref3.optimisticUpdater,
196
+ updater = _ref3.updater,
197
+ uploadables = _ref3.uploadables;
198
+ var optimisticUpdate;
300
199
 
301
- var optimisticUpdate = void 0;
302
200
  if (optimisticResponse || optimisticUpdater) {
303
201
  optimisticUpdate = {
304
202
  operation: operation,
@@ -307,20 +205,27 @@ var RelayModernEnvironment = function () {
307
205
  };
308
206
  }
309
207
 
310
- return this._network.execute(operation.node, operation.variables, { force: true }, uploadables)['do']({
208
+ var node = operation.node;
209
+ return this._network.execute(node.params, operation.variables, {
210
+ force: true
211
+ }, uploadables)["do"]({
311
212
  start: function start() {
312
213
  if (optimisticUpdate) {
313
- _this5._publishQueue.applyUpdate(optimisticUpdate);
314
- _this5._publishQueue.run();
214
+ _this3._publishQueue.applyUpdate(optimisticUpdate);
215
+
216
+ _this3._publishQueue.run();
315
217
  }
316
218
  },
317
219
  next: function next(payload) {
318
220
  if (optimisticUpdate) {
319
- _this5._publishQueue.revertUpdate(optimisticUpdate);
221
+ _this3._publishQueue.revertUpdate(optimisticUpdate);
222
+
320
223
  optimisticUpdate = undefined;
321
224
  }
322
- _this5._publishQueue.commitPayload(operation, require('./normalizePayload')(payload), updater);
323
- _this5._publishQueue.run();
225
+
226
+ _this3._publishQueue.commitPayload(operation, require("./normalizePayload")(operation, payload), updater);
227
+
228
+ _this3._publishQueue.run();
324
229
  },
325
230
  error: function (_error) {
326
231
  function error(_x) {
@@ -334,56 +239,59 @@ var RelayModernEnvironment = function () {
334
239
  return error;
335
240
  }(function (error) {
336
241
  if (optimisticUpdate) {
337
- _this5._publishQueue.revertUpdate(optimisticUpdate);
242
+ _this3._publishQueue.revertUpdate(optimisticUpdate);
243
+
338
244
  optimisticUpdate = undefined;
339
- _this5._publishQueue.run();
245
+
246
+ _this3._publishQueue.run();
340
247
  }
341
248
  }),
342
249
  unsubscribe: function unsubscribe() {
343
250
  if (optimisticUpdate) {
344
- _this5._publishQueue.revertUpdate(optimisticUpdate);
251
+ _this3._publishQueue.revertUpdate(optimisticUpdate);
252
+
345
253
  optimisticUpdate = undefined;
346
- _this5._publishQueue.run();
254
+
255
+ _this3._publishQueue.run();
347
256
  }
348
257
  }
349
258
  });
350
259
  };
351
-
352
260
  /**
353
261
  * @deprecated Use Environment.execute().subscribe()
354
262
  */
355
263
 
356
264
 
357
- RelayModernEnvironment.prototype.sendQuery = function sendQuery(_ref5) {
358
- var cacheConfig = _ref5.cacheConfig,
359
- onCompleted = _ref5.onCompleted,
360
- onError = _ref5.onError,
361
- onNext = _ref5.onNext,
362
- operation = _ref5.operation;
363
-
364
- process.env.NODE_ENV !== 'production' ? require('fbjs/lib/warning')(false, 'environment.sendQuery() is deprecated. Update to the latest ' + 'version of react-relay, and use environment.execute().') : void 0;
365
- return this.execute({ operation: operation, cacheConfig: cacheConfig }).subscribeLegacy({
265
+ _proto.sendQuery = function sendQuery(_ref4) {
266
+ var cacheConfig = _ref4.cacheConfig,
267
+ onCompleted = _ref4.onCompleted,
268
+ onError = _ref4.onError,
269
+ onNext = _ref4.onNext,
270
+ operation = _ref4.operation;
271
+ process.env.NODE_ENV !== "production" ? require("fbjs/lib/warning")(false, 'environment.sendQuery() is deprecated. Update to the latest ' + 'version of react-relay, and use environment.execute().') : void 0;
272
+ return this.execute({
273
+ operation: operation,
274
+ cacheConfig: cacheConfig
275
+ }).subscribeLegacy({
366
276
  onNext: onNext,
367
277
  onError: onError,
368
278
  onCompleted: onCompleted
369
279
  });
370
280
  };
371
-
372
281
  /**
373
282
  * @deprecated Use Environment.executeMutation().subscribe()
374
283
  */
375
284
 
376
285
 
377
- RelayModernEnvironment.prototype.sendMutation = function sendMutation(_ref6) {
378
- var onCompleted = _ref6.onCompleted,
379
- onError = _ref6.onError,
380
- operation = _ref6.operation,
381
- optimisticResponse = _ref6.optimisticResponse,
382
- optimisticUpdater = _ref6.optimisticUpdater,
383
- updater = _ref6.updater,
384
- uploadables = _ref6.uploadables;
385
-
386
- process.env.NODE_ENV !== 'production' ? require('fbjs/lib/warning')(false, 'environment.sendMutation() is deprecated. Update to the latest ' + 'version of react-relay, and use environment.executeMutation().') : void 0;
286
+ _proto.sendMutation = function sendMutation(_ref5) {
287
+ var onCompleted = _ref5.onCompleted,
288
+ onError = _ref5.onError,
289
+ operation = _ref5.operation,
290
+ optimisticResponse = _ref5.optimisticResponse,
291
+ optimisticUpdater = _ref5.optimisticUpdater,
292
+ updater = _ref5.updater,
293
+ uploadables = _ref5.uploadables;
294
+ process.env.NODE_ENV !== "production" ? require("fbjs/lib/warning")(false, 'environment.sendMutation() is deprecated. Update to the latest ' + 'version of react-relay, and use environment.executeMutation().') : void 0;
387
295
  return this.executeMutation({
388
296
  operation: operation,
389
297
  optimisticResponse: optimisticResponse,
@@ -395,21 +303,24 @@ var RelayModernEnvironment = function () {
395
303
  // it a value. When switching to use executeMutation(), the next()
396
304
  // Observer should be used to preserve behavior.
397
305
  onNext: function onNext(payload) {
398
- onCompleted && onCompleted(payload.response.errors);
306
+ onCompleted && onCompleted(payload.errors);
399
307
  },
400
308
  onError: onError,
401
309
  onCompleted: onCompleted
402
310
  });
403
311
  };
404
312
 
405
- return RelayModernEnvironment;
406
- }();
313
+ _proto.toJSON = function toJSON() {
314
+ var _this$configName;
315
+
316
+ return "RelayModernEnvironment(".concat((_this$configName = this.configName) !== null && _this$configName !== void 0 ? _this$configName : '', ")");
317
+ };
407
318
 
408
- // Add a sigil for detection by `isRelayModernEnvironment()` to avoid a
319
+ return RelayModernEnvironment;
320
+ }(); // Add a sigil for detection by `isRelayModernEnvironment()` to avoid a
409
321
  // realm-specific instanceof check, and to aid in module tree-shaking to
410
322
  // avoid requiring all of RelayRuntime just to detect its environment.
411
323
 
412
324
 
413
325
  RelayModernEnvironment.prototype['@@RelayModernEnvironment'] = true;
414
-
415
326
  module.exports = RelayModernEnvironment;