relay-runtime 11.0.1 → 13.0.0-rc.1
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.
- package/handlers/RelayDefaultHandlerProvider.js.flow +2 -2
- package/handlers/connection/ConnectionHandler.js.flow +8 -17
- package/handlers/connection/MutationHandlers.js.flow +7 -11
- package/index.js +1 -1
- package/index.js.flow +60 -36
- package/lib/handlers/RelayDefaultHandlerProvider.js +1 -1
- package/lib/handlers/connection/ConnectionHandler.js +13 -19
- package/lib/handlers/connection/MutationHandlers.js +4 -7
- package/lib/index.js +58 -43
- package/lib/multi-actor-environment/ActorIdentifier.js +33 -0
- package/lib/multi-actor-environment/ActorSpecificEnvironment.js +152 -0
- package/lib/multi-actor-environment/ActorUtils.js +27 -0
- package/lib/multi-actor-environment/MultiActorEnvironment.js +419 -0
- package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +11 -0
- package/lib/multi-actor-environment/index.js +21 -0
- package/lib/mutations/RelayDeclarativeMutationConfig.js +4 -1
- package/lib/mutations/RelayRecordProxy.js +3 -2
- package/lib/mutations/RelayRecordSourceMutator.js +3 -2
- package/lib/mutations/RelayRecordSourceProxy.js +12 -4
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +18 -5
- package/lib/mutations/applyOptimisticMutation.js +6 -6
- package/lib/mutations/commitMutation.js +14 -10
- package/lib/mutations/readUpdatableQuery_EXPERIMENTAL.js +238 -0
- package/lib/mutations/validateMutation.js +10 -5
- package/lib/network/ConvertToExecuteFunction.js +2 -1
- package/lib/network/RelayNetwork.js +3 -2
- package/lib/network/RelayQueryResponseCache.js +21 -5
- package/lib/network/wrapNetworkWithLogObserver.js +79 -0
- package/lib/query/GraphQLTag.js +3 -2
- package/lib/query/fetchQuery.js +6 -5
- package/lib/query/fetchQueryInternal.js +1 -1
- package/lib/query/fetchQuery_DEPRECATED.js +2 -1
- package/lib/store/ClientID.js +7 -1
- package/lib/store/DataChecker.js +123 -54
- package/lib/store/{RelayModernQueryExecutor.js → OperationExecutor.js} +518 -200
- package/lib/store/RelayConcreteVariables.js +26 -8
- package/lib/store/RelayExperimentalGraphResponseHandler.js +153 -0
- package/lib/store/RelayExperimentalGraphResponseTransform.js +391 -0
- package/lib/store/RelayModernEnvironment.js +175 -240
- package/lib/store/RelayModernFragmentSpecResolver.js +52 -26
- package/lib/store/RelayModernOperationDescriptor.js +2 -1
- package/lib/store/RelayModernRecord.js +47 -12
- package/lib/store/RelayModernSelector.js +14 -8
- package/lib/store/RelayModernStore.js +56 -28
- package/lib/store/RelayOperationTracker.js +34 -24
- package/lib/store/RelayPublishQueue.js +41 -13
- package/lib/store/RelayReader.js +288 -48
- package/lib/store/RelayRecordSource.js +87 -3
- package/lib/store/RelayReferenceMarker.js +34 -22
- package/lib/store/RelayResponseNormalizer.js +211 -110
- package/lib/store/RelayStoreReactFlightUtils.js +4 -10
- package/lib/store/RelayStoreSubscriptions.js +14 -9
- package/lib/store/RelayStoreUtils.js +12 -7
- package/lib/store/ResolverCache.js +213 -0
- package/lib/store/ResolverFragments.js +61 -0
- package/lib/store/cloneRelayHandleSourceField.js +5 -4
- package/lib/store/cloneRelayScalarHandleSourceField.js +5 -4
- package/lib/store/createRelayContext.js +4 -2
- package/lib/store/readInlineData.js +6 -2
- package/lib/subscription/requestSubscription.js +34 -25
- package/lib/util/RelayConcreteNode.js +3 -0
- package/lib/util/RelayFeatureFlags.js +10 -4
- package/lib/util/RelayProfiler.js +17 -187
- package/lib/util/RelayReplaySubject.js +22 -7
- package/lib/util/RelayRuntimeTypes.js +0 -6
- package/lib/util/StringInterner.js +71 -0
- package/lib/util/getFragmentIdentifier.js +15 -7
- package/lib/util/getOperation.js +2 -1
- package/lib/util/getPaginationMetadata.js +41 -0
- package/lib/util/getPaginationVariables.js +66 -0
- package/lib/util/getPendingOperationsForFragment.js +55 -0
- package/lib/util/getRefetchMetadata.js +36 -0
- package/lib/util/getRelayHandleKey.js +2 -2
- package/lib/util/getRequestIdentifier.js +2 -2
- package/lib/util/getValueAtPath.js +51 -0
- package/lib/util/isEmptyObject.js +1 -1
- package/lib/util/registerEnvironmentWithDevTools.js +26 -0
- package/lib/util/withDuration.js +31 -0
- package/multi-actor-environment/ActorIdentifier.js.flow +43 -0
- package/multi-actor-environment/ActorSpecificEnvironment.js.flow +225 -0
- package/multi-actor-environment/ActorUtils.js.flow +33 -0
- package/multi-actor-environment/MultiActorEnvironment.js.flow +506 -0
- package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +261 -0
- package/multi-actor-environment/index.js.flow +26 -0
- package/mutations/RelayDeclarativeMutationConfig.js.flow +32 -26
- package/mutations/RelayRecordProxy.js.flow +4 -5
- package/mutations/RelayRecordSourceMutator.js.flow +4 -6
- package/mutations/RelayRecordSourceProxy.js.flow +19 -10
- package/mutations/RelayRecordSourceSelectorProxy.js.flow +22 -7
- package/mutations/applyOptimisticMutation.js.flow +13 -14
- package/mutations/commitLocalUpdate.js.flow +1 -1
- package/mutations/commitMutation.js.flow +35 -46
- package/mutations/readUpdatableQuery_EXPERIMENTAL.js.flow +309 -0
- package/mutations/validateMutation.js.flow +26 -16
- package/network/ConvertToExecuteFunction.js.flow +2 -2
- package/network/RelayNetwork.js.flow +4 -5
- package/network/RelayNetworkTypes.js.flow +5 -4
- package/network/RelayObservable.js.flow +1 -1
- package/network/RelayQueryResponseCache.js.flow +34 -21
- package/network/wrapNetworkWithLogObserver.js.flow +100 -0
- package/package.json +3 -2
- package/query/GraphQLTag.js.flow +9 -9
- package/query/PreloadableQueryRegistry.js.flow +2 -1
- package/query/fetchQuery.js.flow +11 -13
- package/query/fetchQueryInternal.js.flow +6 -9
- package/query/fetchQuery_DEPRECATED.js.flow +6 -6
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/ClientID.js.flow +14 -3
- package/store/DataChecker.js.flow +141 -59
- package/store/{RelayModernQueryExecutor.js.flow → OperationExecutor.js.flow} +605 -303
- package/store/RelayConcreteVariables.js.flow +27 -8
- package/store/RelayExperimentalGraphResponseHandler.js.flow +124 -0
- package/store/RelayExperimentalGraphResponseTransform.js.flow +475 -0
- package/store/RelayModernEnvironment.js.flow +173 -240
- package/store/RelayModernFragmentSpecResolver.js.flow +55 -31
- package/store/RelayModernOperationDescriptor.js.flow +12 -7
- package/store/RelayModernRecord.js.flow +67 -11
- package/store/RelayModernSelector.js.flow +24 -14
- package/store/RelayModernStore.js.flow +66 -36
- package/store/RelayOperationTracker.js.flow +59 -43
- package/store/RelayOptimisticRecordSource.js.flow +2 -2
- package/store/RelayPublishQueue.js.flow +79 -34
- package/store/RelayReader.js.flow +351 -73
- package/store/RelayRecordSource.js.flow +72 -6
- package/store/RelayReferenceMarker.js.flow +40 -26
- package/store/RelayResponseNormalizer.js.flow +258 -99
- package/store/RelayStoreReactFlightUtils.js.flow +4 -11
- package/store/RelayStoreSubscriptions.js.flow +19 -11
- package/store/RelayStoreTypes.js.flow +209 -43
- package/store/RelayStoreUtils.js.flow +24 -11
- package/store/ResolverCache.js.flow +249 -0
- package/store/ResolverFragments.js.flow +121 -0
- package/store/StoreInspector.js.flow +2 -2
- package/store/TypeID.js.flow +1 -1
- package/store/ViewerPattern.js.flow +2 -2
- package/store/cloneRelayHandleSourceField.js.flow +5 -6
- package/store/cloneRelayScalarHandleSourceField.js.flow +5 -6
- package/store/createFragmentSpecResolver.js.flow +3 -4
- package/store/createRelayContext.js.flow +3 -3
- package/store/normalizeRelayPayload.js.flow +6 -7
- package/store/readInlineData.js.flow +7 -8
- package/subscription/requestSubscription.js.flow +53 -41
- package/util/NormalizationNode.js.flow +10 -3
- package/util/ReaderNode.js.flow +38 -2
- package/util/RelayConcreteNode.js.flow +5 -0
- package/util/RelayFeatureFlags.js.flow +24 -10
- package/util/RelayProfiler.js.flow +22 -194
- package/util/RelayReplaySubject.js.flow +9 -9
- package/util/RelayRuntimeTypes.js.flow +72 -3
- package/util/StringInterner.js.flow +69 -0
- package/util/createPayloadFor3DField.js.flow +3 -3
- package/util/getFragmentIdentifier.js.flow +27 -15
- package/util/getOperation.js.flow +2 -2
- package/util/getPaginationMetadata.js.flow +72 -0
- package/util/getPaginationVariables.js.flow +108 -0
- package/util/getPendingOperationsForFragment.js.flow +62 -0
- package/util/getRefetchMetadata.js.flow +79 -0
- package/util/getRelayHandleKey.js.flow +1 -2
- package/util/getRequestIdentifier.js.flow +3 -3
- package/util/getValueAtPath.js.flow +46 -0
- package/util/isEmptyObject.js.flow +1 -0
- package/util/registerEnvironmentWithDevTools.js.flow +33 -0
- package/util/resolveImmediate.js.flow +1 -1
- package/util/withDuration.js.flow +32 -0
- package/lib/store/RelayRecordSourceMapImpl.js +0 -107
- package/lib/store/RelayStoreSubscriptionsUsingMapByID.js +0 -318
- package/store/RelayRecordSourceMapImpl.js.flow +0 -91
- package/store/RelayStoreSubscriptionsUsingMapByID.js.flow +0 -283
|
@@ -17,34 +17,39 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
|
|
|
17
17
|
|
|
18
18
|
var RelayDefaultHandlerProvider = require('../handlers/RelayDefaultHandlerProvider');
|
|
19
19
|
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
var _require = require('../multi-actor-environment/ActorIdentifier'),
|
|
21
|
+
INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE = _require.INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE,
|
|
22
|
+
assertInternalActorIndentifier = _require.assertInternalActorIndentifier;
|
|
23
23
|
|
|
24
24
|
var RelayObservable = require('../network/RelayObservable');
|
|
25
25
|
|
|
26
|
+
var wrapNetworkWithLogObserver = require('../network/wrapNetworkWithLogObserver');
|
|
27
|
+
|
|
26
28
|
var RelayOperationTracker = require('../store/RelayOperationTracker');
|
|
27
29
|
|
|
28
|
-
var
|
|
30
|
+
var registerEnvironmentWithDevTools = require('../util/registerEnvironmentWithDevTools');
|
|
29
31
|
|
|
30
|
-
var
|
|
32
|
+
var RelayFeatureFlags = require('../util/RelayFeatureFlags');
|
|
31
33
|
|
|
32
34
|
var defaultGetDataID = require('./defaultGetDataID');
|
|
33
35
|
|
|
34
36
|
var defaultRequiredFieldLogger = require('./defaultRequiredFieldLogger');
|
|
35
37
|
|
|
36
|
-
var
|
|
38
|
+
var OperationExecutor = require('./OperationExecutor');
|
|
37
39
|
|
|
38
|
-
var
|
|
40
|
+
var RelayPublishQueue = require('./RelayPublishQueue');
|
|
41
|
+
|
|
42
|
+
var RelayRecordSource = require('./RelayRecordSource');
|
|
43
|
+
|
|
44
|
+
var invariant = require('invariant');
|
|
39
45
|
|
|
40
46
|
var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
41
47
|
function RelayModernEnvironment(config) {
|
|
42
48
|
var _this = this;
|
|
43
49
|
|
|
44
|
-
var _config$log, _config$requiredField, _config$UNSTABLE_defa, _config$getDataID, _config$scheduler, _config$isServer, _config$operationTrac;
|
|
50
|
+
var _config$log, _config$requiredField, _config$UNSTABLE_defa, _config$getDataID, _config$handlerProvid, _config$scheduler, _config$isServer, _config$operationTrac;
|
|
45
51
|
|
|
46
52
|
this.configName = config.configName;
|
|
47
|
-
var handlerProvider = config.handlerProvider ? config.handlerProvider : RelayDefaultHandlerProvider;
|
|
48
53
|
this._treatMissingFieldsAsNull = config.treatMissingFieldsAsNull === true;
|
|
49
54
|
var operationLoader = config.operationLoader;
|
|
50
55
|
var reactFlightPayloadDeserializer = config.reactFlightPayloadDeserializer;
|
|
@@ -65,42 +70,35 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
65
70
|
this._defaultRenderPolicy = ((_config$UNSTABLE_defa = config.UNSTABLE_defaultRenderPolicy) !== null && _config$UNSTABLE_defa !== void 0 ? _config$UNSTABLE_defa : RelayFeatureFlags.ENABLE_PARTIAL_RENDERING_DEFAULT === true) ? 'partial' : 'full';
|
|
66
71
|
this._operationLoader = operationLoader;
|
|
67
72
|
this._operationExecutions = new Map();
|
|
68
|
-
this._network = this
|
|
73
|
+
this._network = wrapNetworkWithLogObserver(this, config.network);
|
|
69
74
|
this._getDataID = (_config$getDataID = config.getDataID) !== null && _config$getDataID !== void 0 ? _config$getDataID : defaultGetDataID;
|
|
70
|
-
this._publishQueue = new RelayPublishQueue(config.store, handlerProvider, this._getDataID);
|
|
75
|
+
this._publishQueue = new RelayPublishQueue(config.store, (_config$handlerProvid = config.handlerProvider) !== null && _config$handlerProvid !== void 0 ? _config$handlerProvid : RelayDefaultHandlerProvider, this._getDataID);
|
|
71
76
|
this._scheduler = (_config$scheduler = config.scheduler) !== null && _config$scheduler !== void 0 ? _config$scheduler : null;
|
|
72
77
|
this._store = config.store;
|
|
73
78
|
this.options = config.options;
|
|
74
79
|
this._isServer = (_config$isServer = config.isServer) !== null && _config$isServer !== void 0 ? _config$isServer : false;
|
|
75
80
|
|
|
76
81
|
this.__setNet = function (newNet) {
|
|
77
|
-
return _this._network = _this
|
|
82
|
+
return _this._network = wrapNetworkWithLogObserver(_this, newNet);
|
|
78
83
|
};
|
|
79
84
|
|
|
80
85
|
if (process.env.NODE_ENV !== "production") {
|
|
81
|
-
var
|
|
82
|
-
inspect =
|
|
86
|
+
var _require2 = require('./StoreInspector'),
|
|
87
|
+
inspect = _require2.inspect;
|
|
83
88
|
|
|
84
89
|
this.DEBUG_inspect = function (dataID) {
|
|
85
90
|
return inspect(_this, dataID);
|
|
86
91
|
};
|
|
87
|
-
} // Register this Relay Environment with Relay DevTools if it exists.
|
|
88
|
-
// Note: this must always be the last step in the constructor.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
var _global = typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : undefined;
|
|
92
|
-
|
|
93
|
-
var devToolsHook = _global && _global.__RELAY_DEVTOOLS_HOOK__;
|
|
94
|
-
|
|
95
|
-
if (devToolsHook) {
|
|
96
|
-
devToolsHook.registerEnvironment(this);
|
|
97
92
|
}
|
|
98
93
|
|
|
99
94
|
this._missingFieldHandlers = config.missingFieldHandlers;
|
|
100
95
|
this._operationTracker = (_config$operationTrac = config.operationTracker) !== null && _config$operationTrac !== void 0 ? _config$operationTrac : new RelayOperationTracker();
|
|
101
96
|
this._reactFlightPayloadDeserializer = reactFlightPayloadDeserializer;
|
|
102
97
|
this._reactFlightServerErrorHandler = reactFlightServerErrorHandler;
|
|
103
|
-
this._shouldProcessClientComponents = config.shouldProcessClientComponents;
|
|
98
|
+
this._shouldProcessClientComponents = config.shouldProcessClientComponents; // Register this Relay Environment with Relay DevTools if it exists.
|
|
99
|
+
// Note: this must always be the last step in the constructor.
|
|
100
|
+
|
|
101
|
+
registerEnvironmentWithDevTools(this);
|
|
104
102
|
}
|
|
105
103
|
|
|
106
104
|
var _proto = RelayModernEnvironment.prototype;
|
|
@@ -172,32 +170,16 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
172
170
|
};
|
|
173
171
|
|
|
174
172
|
_proto.applyMutation = function applyMutation(optimisticConfig) {
|
|
175
|
-
var
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
optimisticConfig: optimisticConfig,
|
|
184
|
-
publishQueue: _this5._publishQueue,
|
|
185
|
-
reactFlightPayloadDeserializer: _this5._reactFlightPayloadDeserializer,
|
|
186
|
-
reactFlightServerErrorHandler: _this5._reactFlightServerErrorHandler,
|
|
187
|
-
scheduler: _this5._scheduler,
|
|
188
|
-
sink: sink,
|
|
189
|
-
source: source,
|
|
190
|
-
store: _this5._store,
|
|
191
|
-
updater: null,
|
|
192
|
-
operationTracker: _this5._operationTracker,
|
|
193
|
-
getDataID: _this5._getDataID,
|
|
194
|
-
treatMissingFieldsAsNull: _this5._treatMissingFieldsAsNull,
|
|
195
|
-
shouldProcessClientComponents: _this5._shouldProcessClientComponents
|
|
196
|
-
});
|
|
197
|
-
return function () {
|
|
198
|
-
return executor.cancel();
|
|
199
|
-
};
|
|
173
|
+
var subscription = this._execute({
|
|
174
|
+
createSource: function createSource() {
|
|
175
|
+
return RelayObservable.create(function (_sink) {});
|
|
176
|
+
},
|
|
177
|
+
isClientPayload: false,
|
|
178
|
+
operation: optimisticConfig.operation,
|
|
179
|
+
optimisticConfig: optimisticConfig,
|
|
180
|
+
updater: null
|
|
200
181
|
}).subscribe({});
|
|
182
|
+
|
|
201
183
|
return {
|
|
202
184
|
dispose: function dispose() {
|
|
203
185
|
return subscription.unsubscribe();
|
|
@@ -214,43 +196,26 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
214
196
|
};
|
|
215
197
|
|
|
216
198
|
_proto.commitPayload = function commitPayload(operation, payload) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
var executor = RelayModernQueryExecutor.execute({
|
|
221
|
-
operation: operation,
|
|
222
|
-
operationExecutions: _this6._operationExecutions,
|
|
223
|
-
operationLoader: _this6._operationLoader,
|
|
224
|
-
optimisticConfig: null,
|
|
225
|
-
publishQueue: _this6._publishQueue,
|
|
226
|
-
reactFlightPayloadDeserializer: _this6._reactFlightPayloadDeserializer,
|
|
227
|
-
reactFlightServerErrorHandler: _this6._reactFlightServerErrorHandler,
|
|
228
|
-
scheduler: _this6._scheduler,
|
|
229
|
-
sink: sink,
|
|
230
|
-
source: RelayObservable.from({
|
|
199
|
+
this._execute({
|
|
200
|
+
createSource: function createSource() {
|
|
201
|
+
return RelayObservable.from({
|
|
231
202
|
data: payload
|
|
232
|
-
})
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
treatMissingFieldsAsNull: _this6._treatMissingFieldsAsNull,
|
|
239
|
-
shouldProcessClientComponents: _this6._shouldProcessClientComponents
|
|
240
|
-
});
|
|
241
|
-
return function () {
|
|
242
|
-
return executor.cancel();
|
|
243
|
-
};
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
isClientPayload: true,
|
|
206
|
+
operation: operation,
|
|
207
|
+
optimisticConfig: null,
|
|
208
|
+
updater: null
|
|
244
209
|
}).subscribe({});
|
|
245
210
|
};
|
|
246
211
|
|
|
247
212
|
_proto.commitUpdate = function commitUpdate(updater) {
|
|
248
|
-
var
|
|
213
|
+
var _this5 = this;
|
|
249
214
|
|
|
250
215
|
this._scheduleUpdates(function () {
|
|
251
|
-
|
|
216
|
+
_this5._publishQueue.commitUpdate(updater);
|
|
252
217
|
|
|
253
|
-
|
|
218
|
+
_this5._publishQueue.run();
|
|
254
219
|
});
|
|
255
220
|
};
|
|
256
221
|
|
|
@@ -271,20 +236,30 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
271
236
|
};
|
|
272
237
|
|
|
273
238
|
_proto._checkSelectorAndHandleMissingFields = function _checkSelectorAndHandleMissingFields(operation, handlers) {
|
|
274
|
-
var
|
|
239
|
+
var _this6 = this;
|
|
275
240
|
|
|
276
241
|
var target = RelayRecordSource.create();
|
|
277
242
|
|
|
243
|
+
var source = this._store.getSource();
|
|
244
|
+
|
|
278
245
|
var result = this._store.check(operation, {
|
|
279
|
-
|
|
280
|
-
|
|
246
|
+
handlers: handlers,
|
|
247
|
+
defaultActorIdentifier: INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE,
|
|
248
|
+
getSourceForActor: function getSourceForActor(actorIdentifier) {
|
|
249
|
+
assertInternalActorIndentifier(actorIdentifier);
|
|
250
|
+
return source;
|
|
251
|
+
},
|
|
252
|
+
getTargetForActor: function getTargetForActor(actorIdentifier) {
|
|
253
|
+
assertInternalActorIndentifier(actorIdentifier);
|
|
254
|
+
return target;
|
|
255
|
+
}
|
|
281
256
|
});
|
|
282
257
|
|
|
283
258
|
if (target.size() > 0) {
|
|
284
259
|
this._scheduleUpdates(function () {
|
|
285
|
-
|
|
260
|
+
_this6._publishQueue.commitSource(target);
|
|
286
261
|
|
|
287
|
-
|
|
262
|
+
_this6._publishQueue.run();
|
|
288
263
|
});
|
|
289
264
|
}
|
|
290
265
|
|
|
@@ -302,7 +277,7 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
302
277
|
}
|
|
303
278
|
/**
|
|
304
279
|
* Returns an Observable of GraphQLResponse resulting from executing the
|
|
305
|
-
* provided Query
|
|
280
|
+
* provided Query operation, each result of which is then
|
|
306
281
|
* normalized and committed to the publish queue.
|
|
307
282
|
*
|
|
308
283
|
* Note: Observables are lazy, so calling this method will do nothing until
|
|
@@ -311,34 +286,42 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
311
286
|
;
|
|
312
287
|
|
|
313
288
|
_proto.execute = function execute(_ref) {
|
|
314
|
-
var
|
|
289
|
+
var _this7 = this;
|
|
315
290
|
|
|
316
|
-
var operation = _ref.operation
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
291
|
+
var operation = _ref.operation;
|
|
292
|
+
return this._execute({
|
|
293
|
+
createSource: function createSource() {
|
|
294
|
+
return _this7._network.execute(operation.request.node.params, operation.request.variables, operation.request.cacheConfig || {}, null);
|
|
295
|
+
},
|
|
296
|
+
isClientPayload: false,
|
|
297
|
+
operation: operation,
|
|
298
|
+
optimisticConfig: null,
|
|
299
|
+
updater: null
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Returns an Observable of GraphQLResponse resulting from executing the
|
|
304
|
+
* provided Subscription operation, each result of which is then
|
|
305
|
+
* normalized and committed to the publish queue.
|
|
306
|
+
*
|
|
307
|
+
* Note: Observables are lazy, so calling this method will do nothing until
|
|
308
|
+
* the result is subscribed to: environment.execute({...}).subscribe({...}).
|
|
309
|
+
*/
|
|
310
|
+
;
|
|
320
311
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
operationTracker: _this9._operationTracker,
|
|
335
|
-
getDataID: _this9._getDataID,
|
|
336
|
-
treatMissingFieldsAsNull: _this9._treatMissingFieldsAsNull,
|
|
337
|
-
shouldProcessClientComponents: _this9._shouldProcessClientComponents
|
|
338
|
-
});
|
|
339
|
-
return function () {
|
|
340
|
-
return executor.cancel();
|
|
341
|
-
};
|
|
312
|
+
_proto.executeSubscription = function executeSubscription(_ref2) {
|
|
313
|
+
var _this8 = this;
|
|
314
|
+
|
|
315
|
+
var operation = _ref2.operation,
|
|
316
|
+
updater = _ref2.updater;
|
|
317
|
+
return this._execute({
|
|
318
|
+
createSource: function createSource() {
|
|
319
|
+
return _this8._network.execute(operation.request.node.params, operation.request.variables, operation.request.cacheConfig || {}, null);
|
|
320
|
+
},
|
|
321
|
+
isClientPayload: false,
|
|
322
|
+
operation: operation,
|
|
323
|
+
optimisticConfig: null,
|
|
324
|
+
updater: updater
|
|
342
325
|
});
|
|
343
326
|
}
|
|
344
327
|
/**
|
|
@@ -353,56 +336,40 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
353
336
|
*/
|
|
354
337
|
;
|
|
355
338
|
|
|
356
|
-
_proto.executeMutation = function executeMutation(
|
|
357
|
-
var
|
|
358
|
-
|
|
359
|
-
var operation = _ref2.operation,
|
|
360
|
-
optimisticResponse = _ref2.optimisticResponse,
|
|
361
|
-
optimisticUpdater = _ref2.optimisticUpdater,
|
|
362
|
-
updater = _ref2.updater,
|
|
363
|
-
uploadables = _ref2.uploadables;
|
|
364
|
-
return RelayObservable.create(function (sink) {
|
|
365
|
-
var optimisticConfig;
|
|
366
|
-
|
|
367
|
-
if (optimisticResponse || optimisticUpdater) {
|
|
368
|
-
optimisticConfig = {
|
|
369
|
-
operation: operation,
|
|
370
|
-
response: optimisticResponse,
|
|
371
|
-
updater: optimisticUpdater
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
var source = _this10._network.execute(operation.request.node.params, operation.request.variables, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, operation.request.cacheConfig), {}, {
|
|
376
|
-
force: true
|
|
377
|
-
}), uploadables);
|
|
339
|
+
_proto.executeMutation = function executeMutation(_ref3) {
|
|
340
|
+
var _this9 = this;
|
|
378
341
|
|
|
379
|
-
|
|
342
|
+
var operation = _ref3.operation,
|
|
343
|
+
optimisticResponse = _ref3.optimisticResponse,
|
|
344
|
+
optimisticUpdater = _ref3.optimisticUpdater,
|
|
345
|
+
updater = _ref3.updater,
|
|
346
|
+
uploadables = _ref3.uploadables;
|
|
347
|
+
var optimisticConfig;
|
|
348
|
+
|
|
349
|
+
if (optimisticResponse || optimisticUpdater) {
|
|
350
|
+
optimisticConfig = {
|
|
380
351
|
operation: operation,
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
optimisticConfig: optimisticConfig,
|
|
384
|
-
publishQueue: _this10._publishQueue,
|
|
385
|
-
reactFlightPayloadDeserializer: _this10._reactFlightPayloadDeserializer,
|
|
386
|
-
reactFlightServerErrorHandler: _this10._reactFlightServerErrorHandler,
|
|
387
|
-
scheduler: _this10._scheduler,
|
|
388
|
-
sink: sink,
|
|
389
|
-
source: source,
|
|
390
|
-
store: _this10._store,
|
|
391
|
-
updater: updater,
|
|
392
|
-
operationTracker: _this10._operationTracker,
|
|
393
|
-
getDataID: _this10._getDataID,
|
|
394
|
-
treatMissingFieldsAsNull: _this10._treatMissingFieldsAsNull,
|
|
395
|
-
shouldProcessClientComponents: _this10._shouldProcessClientComponents
|
|
396
|
-
});
|
|
397
|
-
return function () {
|
|
398
|
-
return executor.cancel();
|
|
352
|
+
response: optimisticResponse,
|
|
353
|
+
updater: optimisticUpdater
|
|
399
354
|
};
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
return this._execute({
|
|
358
|
+
createSource: function createSource() {
|
|
359
|
+
return _this9._network.execute(operation.request.node.params, operation.request.variables, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, operation.request.cacheConfig), {}, {
|
|
360
|
+
force: true
|
|
361
|
+
}), uploadables);
|
|
362
|
+
},
|
|
363
|
+
isClientPayload: false,
|
|
364
|
+
operation: operation,
|
|
365
|
+
optimisticConfig: optimisticConfig,
|
|
366
|
+
updater: updater
|
|
400
367
|
});
|
|
401
368
|
}
|
|
402
369
|
/**
|
|
403
370
|
* Returns an Observable of GraphQLResponse resulting from executing the
|
|
404
371
|
* provided Query or Subscription operation responses, the result of which is
|
|
405
|
-
* then normalized and
|
|
372
|
+
* then normalized and committed to the publish queue.
|
|
406
373
|
*
|
|
407
374
|
* Note: Observables are lazy, so calling this method will do nothing until
|
|
408
375
|
* the result is subscribed to:
|
|
@@ -410,28 +377,65 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
410
377
|
*/
|
|
411
378
|
;
|
|
412
379
|
|
|
413
|
-
_proto.executeWithSource = function executeWithSource(
|
|
414
|
-
var
|
|
380
|
+
_proto.executeWithSource = function executeWithSource(_ref4) {
|
|
381
|
+
var operation = _ref4.operation,
|
|
382
|
+
source = _ref4.source;
|
|
383
|
+
return this._execute({
|
|
384
|
+
createSource: function createSource() {
|
|
385
|
+
return source;
|
|
386
|
+
},
|
|
387
|
+
isClientPayload: false,
|
|
388
|
+
operation: operation,
|
|
389
|
+
optimisticConfig: null,
|
|
390
|
+
updater: null
|
|
391
|
+
});
|
|
392
|
+
};
|
|
415
393
|
|
|
416
|
-
|
|
417
|
-
|
|
394
|
+
_proto.toJSON = function toJSON() {
|
|
395
|
+
var _this$configName;
|
|
396
|
+
|
|
397
|
+
return "RelayModernEnvironment(".concat((_this$configName = this.configName) !== null && _this$configName !== void 0 ? _this$configName : '', ")");
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
_proto._execute = function _execute(_ref5) {
|
|
401
|
+
var _this10 = this;
|
|
402
|
+
|
|
403
|
+
var createSource = _ref5.createSource,
|
|
404
|
+
isClientPayload = _ref5.isClientPayload,
|
|
405
|
+
operation = _ref5.operation,
|
|
406
|
+
optimisticConfig = _ref5.optimisticConfig,
|
|
407
|
+
updater = _ref5.updater;
|
|
408
|
+
var publishQueue = this._publishQueue;
|
|
409
|
+
var store = this._store;
|
|
418
410
|
return RelayObservable.create(function (sink) {
|
|
419
|
-
var executor =
|
|
411
|
+
var executor = OperationExecutor.execute({
|
|
412
|
+
actorIdentifier: INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE,
|
|
413
|
+
getDataID: _this10._getDataID,
|
|
414
|
+
isClientPayload: isClientPayload,
|
|
415
|
+
log: _this10.__log,
|
|
420
416
|
operation: operation,
|
|
421
|
-
operationExecutions:
|
|
422
|
-
operationLoader:
|
|
423
|
-
operationTracker:
|
|
424
|
-
optimisticConfig:
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
417
|
+
operationExecutions: _this10._operationExecutions,
|
|
418
|
+
operationLoader: _this10._operationLoader,
|
|
419
|
+
operationTracker: _this10._operationTracker,
|
|
420
|
+
optimisticConfig: optimisticConfig,
|
|
421
|
+
getPublishQueue: function getPublishQueue(actorIdentifier) {
|
|
422
|
+
assertInternalActorIndentifier(actorIdentifier);
|
|
423
|
+
return publishQueue;
|
|
424
|
+
},
|
|
425
|
+
reactFlightPayloadDeserializer: _this10._reactFlightPayloadDeserializer,
|
|
426
|
+
reactFlightServerErrorHandler: _this10._reactFlightServerErrorHandler,
|
|
427
|
+
scheduler: _this10._scheduler,
|
|
428
|
+
shouldProcessClientComponents: _this10._shouldProcessClientComponents,
|
|
429
429
|
sink: sink,
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
430
|
+
// NOTE: Some product tests expect `Network.execute` to be called only
|
|
431
|
+
// when the Observable is executed.
|
|
432
|
+
source: createSource(),
|
|
433
|
+
getStore: function getStore(actorIdentifier) {
|
|
434
|
+
assertInternalActorIndentifier(actorIdentifier);
|
|
435
|
+
return store;
|
|
436
|
+
},
|
|
437
|
+
treatMissingFieldsAsNull: _this10._treatMissingFieldsAsNull,
|
|
438
|
+
updater: updater
|
|
435
439
|
});
|
|
436
440
|
return function () {
|
|
437
441
|
return executor.cancel();
|
|
@@ -439,75 +443,6 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
439
443
|
});
|
|
440
444
|
};
|
|
441
445
|
|
|
442
|
-
_proto.toJSON = function toJSON() {
|
|
443
|
-
var _this$configName;
|
|
444
|
-
|
|
445
|
-
return "RelayModernEnvironment(".concat((_this$configName = this.configName) !== null && _this$configName !== void 0 ? _this$configName : '', ")");
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* Wraps the network with logging to ensure that network requests are
|
|
449
|
-
* always logged. Relying on each network callsite to be wrapped is
|
|
450
|
-
* untenable and will eventually lead to holes in the logging.
|
|
451
|
-
*/
|
|
452
|
-
;
|
|
453
|
-
|
|
454
|
-
_proto.__wrapNetworkWithLogObserver = function __wrapNetworkWithLogObserver(network) {
|
|
455
|
-
var that = this;
|
|
456
|
-
return {
|
|
457
|
-
execute: function execute(params, variables, cacheConfig, uploadables) {
|
|
458
|
-
var transactionID = generateID();
|
|
459
|
-
var log = that.__log;
|
|
460
|
-
var logObserver = {
|
|
461
|
-
start: function start(subscription) {
|
|
462
|
-
log({
|
|
463
|
-
name: 'network.start',
|
|
464
|
-
transactionID: transactionID,
|
|
465
|
-
params: params,
|
|
466
|
-
variables: variables,
|
|
467
|
-
cacheConfig: cacheConfig
|
|
468
|
-
});
|
|
469
|
-
},
|
|
470
|
-
next: function next(response) {
|
|
471
|
-
log({
|
|
472
|
-
name: 'network.next',
|
|
473
|
-
transactionID: transactionID,
|
|
474
|
-
response: response
|
|
475
|
-
});
|
|
476
|
-
},
|
|
477
|
-
error: function error(_error) {
|
|
478
|
-
log({
|
|
479
|
-
name: 'network.error',
|
|
480
|
-
transactionID: transactionID,
|
|
481
|
-
error: _error
|
|
482
|
-
});
|
|
483
|
-
},
|
|
484
|
-
complete: function complete() {
|
|
485
|
-
log({
|
|
486
|
-
name: 'network.complete',
|
|
487
|
-
transactionID: transactionID
|
|
488
|
-
});
|
|
489
|
-
},
|
|
490
|
-
unsubscribe: function unsubscribe() {
|
|
491
|
-
log({
|
|
492
|
-
name: 'network.unsubscribe',
|
|
493
|
-
transactionID: transactionID
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
|
|
498
|
-
var logRequestInfo = function logRequestInfo(info) {
|
|
499
|
-
log({
|
|
500
|
-
name: 'network.info',
|
|
501
|
-
transactionID: transactionID,
|
|
502
|
-
info: info
|
|
503
|
-
});
|
|
504
|
-
};
|
|
505
|
-
|
|
506
|
-
return network.execute(params, variables, cacheConfig, uploadables, logRequestInfo)["do"](logObserver);
|
|
507
|
-
}
|
|
508
|
-
};
|
|
509
|
-
};
|
|
510
|
-
|
|
511
446
|
return RelayModernEnvironment;
|
|
512
447
|
}(); // Add a sigil for detection by `isRelayModernEnvironment()` to avoid a
|
|
513
448
|
// realm-specific instanceof check, and to aid in module tree-shaking to
|