relay-runtime 11.0.0-rc.0 → 12.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.
- package/handlers/connection/ConnectionHandler.js.flow +7 -0
- package/handlers/connection/MutationHandlers.js.flow +28 -0
- package/index.js +1 -1
- package/index.js.flow +20 -3
- package/lib/handlers/RelayDefaultHandlerProvider.js +1 -1
- package/lib/handlers/connection/ConnectionHandler.js +12 -6
- package/lib/handlers/connection/MutationHandlers.js +67 -8
- package/lib/index.js +15 -0
- package/lib/multi-actor-environment/ActorIdentifier.js +33 -0
- package/lib/multi-actor-environment/ActorSpecificEnvironment.js +148 -0
- package/lib/multi-actor-environment/ActorUtils.js +27 -0
- package/lib/multi-actor-environment/MultiActorEnvironment.js +406 -0
- package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +11 -0
- package/lib/multi-actor-environment/index.js +21 -0
- package/lib/mutations/RelayRecordProxy.js +1 -1
- package/lib/mutations/RelayRecordSourceMutator.js +1 -1
- package/lib/mutations/RelayRecordSourceProxy.js +1 -1
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +7 -2
- package/lib/mutations/applyOptimisticMutation.js +1 -1
- package/lib/mutations/commitMutation.js +5 -2
- package/lib/mutations/validateMutation.js +39 -17
- package/lib/network/RelayNetwork.js +1 -1
- package/lib/network/RelayObservable.js +3 -1
- package/lib/network/RelayQueryResponseCache.js +20 -3
- package/lib/network/wrapNetworkWithLogObserver.js +78 -0
- package/lib/query/GraphQLTag.js +1 -1
- package/lib/query/fetchQuery.js +1 -1
- package/lib/query/fetchQueryInternal.js +1 -1
- package/lib/store/DataChecker.js +132 -50
- package/lib/store/{RelayModernQueryExecutor.js → OperationExecutor.js} +524 -187
- package/lib/store/RelayConcreteVariables.js +29 -4
- package/lib/store/RelayModernEnvironment.js +137 -220
- package/lib/store/RelayModernFragmentSpecResolver.js +49 -23
- package/lib/store/RelayModernRecord.js +36 -2
- package/lib/store/RelayModernSelector.js +1 -1
- package/lib/store/RelayModernStore.js +53 -22
- package/lib/store/RelayOperationTracker.js +34 -24
- package/lib/store/RelayPublishQueue.js +30 -8
- package/lib/store/RelayReader.js +177 -29
- package/lib/store/RelayRecordSource.js +87 -3
- package/lib/store/RelayReferenceMarker.js +53 -28
- package/lib/store/RelayResponseNormalizer.js +247 -108
- package/lib/store/RelayStoreReactFlightUtils.js +7 -11
- package/lib/store/RelayStoreSubscriptions.js +8 -5
- package/lib/store/RelayStoreUtils.js +10 -4
- package/lib/store/ResolverCache.js +213 -0
- package/lib/store/ResolverFragments.js +57 -0
- package/lib/store/cloneRelayHandleSourceField.js +1 -1
- package/lib/store/cloneRelayScalarHandleSourceField.js +1 -1
- package/lib/store/createRelayContext.js +2 -2
- package/lib/store/defaultGetDataID.js +3 -1
- package/lib/store/readInlineData.js +1 -1
- package/lib/subscription/requestSubscription.js +32 -6
- package/lib/util/RelayConcreteNode.js +3 -0
- package/lib/util/RelayFeatureFlags.js +5 -4
- package/lib/util/RelayProfiler.js +17 -187
- package/lib/util/RelayReplaySubject.js +22 -7
- package/lib/util/deepFreeze.js +1 -0
- package/lib/util/getPaginationMetadata.js +41 -0
- package/lib/util/getPaginationVariables.js +67 -0
- package/lib/util/getPendingOperationsForFragment.js +55 -0
- package/lib/util/getRefetchMetadata.js +36 -0
- package/lib/util/getRelayHandleKey.js +1 -1
- package/lib/util/getRequestIdentifier.js +1 -1
- 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 +217 -0
- package/multi-actor-environment/ActorUtils.js.flow +33 -0
- package/multi-actor-environment/MultiActorEnvironment.js.flow +485 -0
- package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +245 -0
- package/multi-actor-environment/index.js.flow +27 -0
- package/mutations/RelayRecordSourceSelectorProxy.js.flow +7 -2
- package/mutations/commitMutation.js.flow +3 -1
- package/mutations/validateMutation.js.flow +42 -16
- package/network/RelayNetworkTypes.js.flow +17 -8
- package/network/RelayObservable.js.flow +2 -0
- package/network/RelayQueryResponseCache.js.flow +31 -17
- package/network/wrapNetworkWithLogObserver.js.flow +99 -0
- package/package.json +3 -2
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/ClientID.js.flow +5 -1
- package/store/DataChecker.js.flow +148 -44
- package/store/{RelayModernQueryExecutor.js.flow → OperationExecutor.js.flow} +578 -237
- package/store/RelayConcreteVariables.js.flow +31 -1
- package/store/RelayModernEnvironment.js.flow +132 -220
- package/store/RelayModernFragmentSpecResolver.js.flow +40 -14
- package/store/RelayModernOperationDescriptor.js.flow +9 -3
- package/store/RelayModernRecord.js.flow +49 -0
- package/store/RelayModernStore.js.flow +57 -17
- package/store/RelayOperationTracker.js.flow +56 -34
- package/store/RelayPublishQueue.js.flow +37 -11
- package/store/RelayReader.js.flow +186 -27
- package/store/RelayRecordSource.js.flow +72 -6
- package/store/RelayReferenceMarker.js.flow +51 -21
- package/store/RelayResponseNormalizer.js.flow +251 -67
- package/store/RelayStoreReactFlightUtils.js.flow +6 -9
- package/store/RelayStoreSubscriptions.js.flow +10 -3
- package/store/RelayStoreTypes.js.flow +144 -21
- package/store/RelayStoreUtils.js.flow +19 -4
- package/store/ResolverCache.js.flow +247 -0
- package/store/ResolverFragments.js.flow +128 -0
- package/store/createRelayContext.js.flow +1 -1
- package/store/defaultGetDataID.js.flow +3 -1
- package/subscription/requestSubscription.js.flow +43 -8
- package/util/NormalizationNode.js.flow +16 -3
- package/util/ReaderNode.js.flow +29 -2
- package/util/RelayConcreteNode.js.flow +3 -0
- package/util/RelayFeatureFlags.js.flow +10 -6
- package/util/RelayProfiler.js.flow +22 -194
- package/util/RelayReplaySubject.js.flow +7 -6
- package/util/RelayRuntimeTypes.js.flow +4 -2
- package/util/deepFreeze.js.flow +2 -1
- package/util/getPaginationMetadata.js.flow +74 -0
- package/util/getPaginationVariables.js.flow +112 -0
- package/util/getPendingOperationsForFragment.js.flow +62 -0
- package/util/getRefetchMetadata.js.flow +80 -0
- package/util/getValueAtPath.js.flow +46 -0
- package/util/isEmptyObject.js.flow +2 -1
- package/util/registerEnvironmentWithDevTools.js.flow +33 -0
- 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
|
@@ -14,7 +14,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
14
14
|
|
|
15
15
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
16
16
|
|
|
17
|
-
var invariant = require(
|
|
17
|
+
var invariant = require('invariant');
|
|
18
|
+
|
|
19
|
+
var _require = require('./RelayStoreUtils'),
|
|
20
|
+
getArgumentValues = _require.getArgumentValues;
|
|
18
21
|
|
|
19
22
|
/**
|
|
20
23
|
* Determines the variables that are in scope for a fragment given the variables
|
|
@@ -28,7 +31,8 @@ function getFragmentVariables(fragment, rootVariables, argumentVariables) {
|
|
|
28
31
|
fragment.argumentDefinitions.forEach(function (definition) {
|
|
29
32
|
if (argumentVariables.hasOwnProperty(definition.name)) {
|
|
30
33
|
return;
|
|
31
|
-
}
|
|
34
|
+
} // $FlowFixMe[cannot-spread-interface]
|
|
35
|
+
|
|
32
36
|
|
|
33
37
|
variables = variables || (0, _objectSpread2["default"])({}, argumentVariables);
|
|
34
38
|
|
|
@@ -48,9 +52,12 @@ function getFragmentVariables(fragment, rootVariables, argumentVariables) {
|
|
|
48
52
|
* RelayStoreUtils.getStableVariableValue() that variable keys are all
|
|
49
53
|
* present.
|
|
50
54
|
*/
|
|
55
|
+
// $FlowFixMe[incompatible-use]
|
|
51
56
|
variables[definition.name] = undefined;
|
|
52
57
|
break;
|
|
53
|
-
}
|
|
58
|
+
} // $FlowFixMe[incompatible-use]
|
|
59
|
+
// $FlowFixMe[cannot-write]
|
|
60
|
+
|
|
54
61
|
|
|
55
62
|
variables[definition.name] = rootVariables[definition.name];
|
|
56
63
|
break;
|
|
@@ -73,7 +80,7 @@ function getFragmentVariables(fragment, rootVariables, argumentVariables) {
|
|
|
73
80
|
function getOperationVariables(operation, variables) {
|
|
74
81
|
var operationVariables = {};
|
|
75
82
|
operation.argumentDefinitions.forEach(function (def) {
|
|
76
|
-
var value = def.defaultValue;
|
|
83
|
+
var value = def.defaultValue; // $FlowFixMe[cannot-write]
|
|
77
84
|
|
|
78
85
|
if (variables[def.name] != null) {
|
|
79
86
|
value = variables[def.name];
|
|
@@ -84,7 +91,25 @@ function getOperationVariables(operation, variables) {
|
|
|
84
91
|
return operationVariables;
|
|
85
92
|
}
|
|
86
93
|
|
|
94
|
+
function getLocalVariables(currentVariables, argumentDefinitions, args) {
|
|
95
|
+
if (argumentDefinitions == null) {
|
|
96
|
+
return currentVariables;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
var nextVariables = (0, _objectSpread2["default"])({}, currentVariables);
|
|
100
|
+
var nextArgs = args ? getArgumentValues(args, currentVariables) : {};
|
|
101
|
+
argumentDefinitions.forEach(function (def) {
|
|
102
|
+
var _nextArgs$def$name;
|
|
103
|
+
|
|
104
|
+
// $FlowFixMe[cannot-write]
|
|
105
|
+
var value = (_nextArgs$def$name = nextArgs[def.name]) !== null && _nextArgs$def$name !== void 0 ? _nextArgs$def$name : def.defaultValue;
|
|
106
|
+
nextVariables[def.name] = value;
|
|
107
|
+
});
|
|
108
|
+
return nextVariables;
|
|
109
|
+
}
|
|
110
|
+
|
|
87
111
|
module.exports = {
|
|
112
|
+
getLocalVariables: getLocalVariables,
|
|
88
113
|
getFragmentVariables: getFragmentVariables,
|
|
89
114
|
getOperationVariables: getOperationVariables
|
|
90
115
|
};
|
|
@@ -15,12 +15,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
15
15
|
|
|
16
16
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
17
17
|
|
|
18
|
+
var OperationExecutor = require('./OperationExecutor');
|
|
19
|
+
|
|
18
20
|
var RelayDefaultHandlerProvider = require('../handlers/RelayDefaultHandlerProvider');
|
|
19
21
|
|
|
20
22
|
var RelayFeatureFlags = require('../util/RelayFeatureFlags');
|
|
21
23
|
|
|
22
|
-
var RelayModernQueryExecutor = require('./RelayModernQueryExecutor');
|
|
23
|
-
|
|
24
24
|
var RelayObservable = require('../network/RelayObservable');
|
|
25
25
|
|
|
26
26
|
var RelayOperationTracker = require('../store/RelayOperationTracker');
|
|
@@ -33,18 +33,23 @@ var defaultGetDataID = require('./defaultGetDataID');
|
|
|
33
33
|
|
|
34
34
|
var defaultRequiredFieldLogger = require('./defaultRequiredFieldLogger');
|
|
35
35
|
|
|
36
|
-
var
|
|
36
|
+
var invariant = require('invariant');
|
|
37
|
+
|
|
38
|
+
var registerEnvironmentWithDevTools = require('../util/registerEnvironmentWithDevTools');
|
|
37
39
|
|
|
38
|
-
var
|
|
40
|
+
var wrapNetworkWithLogObserver = require('../network/wrapNetworkWithLogObserver');
|
|
41
|
+
|
|
42
|
+
var _require = require('../multi-actor-environment/ActorIdentifier'),
|
|
43
|
+
INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE = _require.INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE,
|
|
44
|
+
assertInternalActorIndentifier = _require.assertInternalActorIndentifier;
|
|
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,41 +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;
|
|
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);
|
|
103
102
|
}
|
|
104
103
|
|
|
105
104
|
var _proto = RelayModernEnvironment.prototype;
|
|
@@ -171,31 +170,16 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
171
170
|
};
|
|
172
171
|
|
|
173
172
|
_proto.applyMutation = function applyMutation(optimisticConfig) {
|
|
174
|
-
var
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
optimisticConfig: optimisticConfig,
|
|
183
|
-
publishQueue: _this5._publishQueue,
|
|
184
|
-
reactFlightPayloadDeserializer: _this5._reactFlightPayloadDeserializer,
|
|
185
|
-
reactFlightServerErrorHandler: _this5._reactFlightServerErrorHandler,
|
|
186
|
-
scheduler: _this5._scheduler,
|
|
187
|
-
sink: sink,
|
|
188
|
-
source: source,
|
|
189
|
-
store: _this5._store,
|
|
190
|
-
updater: null,
|
|
191
|
-
operationTracker: _this5._operationTracker,
|
|
192
|
-
getDataID: _this5._getDataID,
|
|
193
|
-
treatMissingFieldsAsNull: _this5._treatMissingFieldsAsNull
|
|
194
|
-
});
|
|
195
|
-
return function () {
|
|
196
|
-
return executor.cancel();
|
|
197
|
-
};
|
|
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
|
|
198
181
|
}).subscribe({});
|
|
182
|
+
|
|
199
183
|
return {
|
|
200
184
|
dispose: function dispose() {
|
|
201
185
|
return subscription.unsubscribe();
|
|
@@ -212,42 +196,26 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
212
196
|
};
|
|
213
197
|
|
|
214
198
|
_proto.commitPayload = function commitPayload(operation, payload) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
var executor = RelayModernQueryExecutor.execute({
|
|
219
|
-
operation: operation,
|
|
220
|
-
operationExecutions: _this6._operationExecutions,
|
|
221
|
-
operationLoader: _this6._operationLoader,
|
|
222
|
-
optimisticConfig: null,
|
|
223
|
-
publishQueue: _this6._publishQueue,
|
|
224
|
-
reactFlightPayloadDeserializer: _this6._reactFlightPayloadDeserializer,
|
|
225
|
-
reactFlightServerErrorHandler: _this6._reactFlightServerErrorHandler,
|
|
226
|
-
scheduler: _this6._scheduler,
|
|
227
|
-
sink: sink,
|
|
228
|
-
source: RelayObservable.from({
|
|
199
|
+
this._execute({
|
|
200
|
+
createSource: function createSource() {
|
|
201
|
+
return RelayObservable.from({
|
|
229
202
|
data: payload
|
|
230
|
-
})
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
treatMissingFieldsAsNull: _this6._treatMissingFieldsAsNull
|
|
237
|
-
});
|
|
238
|
-
return function () {
|
|
239
|
-
return executor.cancel();
|
|
240
|
-
};
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
isClientPayload: true,
|
|
206
|
+
operation: operation,
|
|
207
|
+
optimisticConfig: null,
|
|
208
|
+
updater: null
|
|
241
209
|
}).subscribe({});
|
|
242
210
|
};
|
|
243
211
|
|
|
244
212
|
_proto.commitUpdate = function commitUpdate(updater) {
|
|
245
|
-
var
|
|
213
|
+
var _this5 = this;
|
|
246
214
|
|
|
247
215
|
this._scheduleUpdates(function () {
|
|
248
|
-
|
|
216
|
+
_this5._publishQueue.commitUpdate(updater);
|
|
249
217
|
|
|
250
|
-
|
|
218
|
+
_this5._publishQueue.run();
|
|
251
219
|
});
|
|
252
220
|
};
|
|
253
221
|
|
|
@@ -268,20 +236,30 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
268
236
|
};
|
|
269
237
|
|
|
270
238
|
_proto._checkSelectorAndHandleMissingFields = function _checkSelectorAndHandleMissingFields(operation, handlers) {
|
|
271
|
-
var
|
|
239
|
+
var _this6 = this;
|
|
272
240
|
|
|
273
241
|
var target = RelayRecordSource.create();
|
|
274
242
|
|
|
243
|
+
var source = this._store.getSource();
|
|
244
|
+
|
|
275
245
|
var result = this._store.check(operation, {
|
|
276
|
-
|
|
277
|
-
|
|
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
|
+
}
|
|
278
256
|
});
|
|
279
257
|
|
|
280
258
|
if (target.size() > 0) {
|
|
281
259
|
this._scheduleUpdates(function () {
|
|
282
|
-
|
|
260
|
+
_this6._publishQueue.commitSource(target);
|
|
283
261
|
|
|
284
|
-
|
|
262
|
+
_this6._publishQueue.run();
|
|
285
263
|
});
|
|
286
264
|
}
|
|
287
265
|
|
|
@@ -308,33 +286,18 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
308
286
|
;
|
|
309
287
|
|
|
310
288
|
_proto.execute = function execute(_ref) {
|
|
311
|
-
var
|
|
289
|
+
var _this7 = this;
|
|
312
290
|
|
|
313
291
|
var operation = _ref.operation,
|
|
314
292
|
updater = _ref.updater;
|
|
315
|
-
return
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
publishQueue: _this9._publishQueue,
|
|
324
|
-
reactFlightPayloadDeserializer: _this9._reactFlightPayloadDeserializer,
|
|
325
|
-
reactFlightServerErrorHandler: _this9._reactFlightServerErrorHandler,
|
|
326
|
-
scheduler: _this9._scheduler,
|
|
327
|
-
sink: sink,
|
|
328
|
-
source: source,
|
|
329
|
-
store: _this9._store,
|
|
330
|
-
updater: updater,
|
|
331
|
-
operationTracker: _this9._operationTracker,
|
|
332
|
-
getDataID: _this9._getDataID,
|
|
333
|
-
treatMissingFieldsAsNull: _this9._treatMissingFieldsAsNull
|
|
334
|
-
});
|
|
335
|
-
return function () {
|
|
336
|
-
return executor.cancel();
|
|
337
|
-
};
|
|
293
|
+
return this._execute({
|
|
294
|
+
createSource: function createSource() {
|
|
295
|
+
return _this7._network.execute(operation.request.node.params, operation.request.variables, operation.request.cacheConfig || {}, null);
|
|
296
|
+
},
|
|
297
|
+
isClientPayload: false,
|
|
298
|
+
operation: operation,
|
|
299
|
+
optimisticConfig: null,
|
|
300
|
+
updater: updater
|
|
338
301
|
});
|
|
339
302
|
}
|
|
340
303
|
/**
|
|
@@ -350,54 +313,39 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
350
313
|
;
|
|
351
314
|
|
|
352
315
|
_proto.executeMutation = function executeMutation(_ref2) {
|
|
353
|
-
var
|
|
316
|
+
var _this8 = this;
|
|
354
317
|
|
|
355
318
|
var operation = _ref2.operation,
|
|
356
319
|
optimisticResponse = _ref2.optimisticResponse,
|
|
357
320
|
optimisticUpdater = _ref2.optimisticUpdater,
|
|
358
321
|
updater = _ref2.updater,
|
|
359
322
|
uploadables = _ref2.uploadables;
|
|
360
|
-
|
|
361
|
-
var optimisticConfig;
|
|
362
|
-
|
|
363
|
-
if (optimisticResponse || optimisticUpdater) {
|
|
364
|
-
optimisticConfig = {
|
|
365
|
-
operation: operation,
|
|
366
|
-
response: optimisticResponse,
|
|
367
|
-
updater: optimisticUpdater
|
|
368
|
-
};
|
|
369
|
-
}
|
|
323
|
+
var optimisticConfig;
|
|
370
324
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}), uploadables);
|
|
374
|
-
|
|
375
|
-
var executor = RelayModernQueryExecutor.execute({
|
|
325
|
+
if (optimisticResponse || optimisticUpdater) {
|
|
326
|
+
optimisticConfig = {
|
|
376
327
|
operation: operation,
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
optimisticConfig: optimisticConfig,
|
|
380
|
-
publishQueue: _this10._publishQueue,
|
|
381
|
-
reactFlightPayloadDeserializer: _this10._reactFlightPayloadDeserializer,
|
|
382
|
-
reactFlightServerErrorHandler: _this10._reactFlightServerErrorHandler,
|
|
383
|
-
scheduler: _this10._scheduler,
|
|
384
|
-
sink: sink,
|
|
385
|
-
source: source,
|
|
386
|
-
store: _this10._store,
|
|
387
|
-
updater: updater,
|
|
388
|
-
operationTracker: _this10._operationTracker,
|
|
389
|
-
getDataID: _this10._getDataID,
|
|
390
|
-
treatMissingFieldsAsNull: _this10._treatMissingFieldsAsNull
|
|
391
|
-
});
|
|
392
|
-
return function () {
|
|
393
|
-
return executor.cancel();
|
|
328
|
+
response: optimisticResponse,
|
|
329
|
+
updater: optimisticUpdater
|
|
394
330
|
};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return this._execute({
|
|
334
|
+
createSource: function createSource() {
|
|
335
|
+
return _this8._network.execute(operation.request.node.params, operation.request.variables, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, operation.request.cacheConfig), {}, {
|
|
336
|
+
force: true
|
|
337
|
+
}), uploadables);
|
|
338
|
+
},
|
|
339
|
+
isClientPayload: false,
|
|
340
|
+
operation: operation,
|
|
341
|
+
optimisticConfig: optimisticConfig,
|
|
342
|
+
updater: updater
|
|
395
343
|
});
|
|
396
344
|
}
|
|
397
345
|
/**
|
|
398
346
|
* Returns an Observable of GraphQLResponse resulting from executing the
|
|
399
347
|
* provided Query or Subscription operation responses, the result of which is
|
|
400
|
-
* then normalized and
|
|
348
|
+
* then normalized and committed to the publish queue.
|
|
401
349
|
*
|
|
402
350
|
* Note: Observables are lazy, so calling this method will do nothing until
|
|
403
351
|
* the result is subscribed to:
|
|
@@ -406,30 +354,16 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
406
354
|
;
|
|
407
355
|
|
|
408
356
|
_proto.executeWithSource = function executeWithSource(_ref3) {
|
|
409
|
-
var _this11 = this;
|
|
410
|
-
|
|
411
357
|
var operation = _ref3.operation,
|
|
412
358
|
source = _ref3.source;
|
|
413
|
-
return
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
reactFlightPayloadDeserializer: _this11._reactFlightPayloadDeserializer,
|
|
422
|
-
reactFlightServerErrorHandler: _this11._reactFlightServerErrorHandler,
|
|
423
|
-
scheduler: _this11._scheduler,
|
|
424
|
-
sink: sink,
|
|
425
|
-
source: source,
|
|
426
|
-
store: _this11._store,
|
|
427
|
-
getDataID: _this11._getDataID,
|
|
428
|
-
treatMissingFieldsAsNull: _this11._treatMissingFieldsAsNull
|
|
429
|
-
});
|
|
430
|
-
return function () {
|
|
431
|
-
return executor.cancel();
|
|
432
|
-
};
|
|
359
|
+
return this._execute({
|
|
360
|
+
createSource: function createSource() {
|
|
361
|
+
return source;
|
|
362
|
+
},
|
|
363
|
+
isClientPayload: false,
|
|
364
|
+
operation: operation,
|
|
365
|
+
optimisticConfig: null,
|
|
366
|
+
updater: null
|
|
433
367
|
});
|
|
434
368
|
};
|
|
435
369
|
|
|
@@ -437,69 +371,52 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
437
371
|
var _this$configName;
|
|
438
372
|
|
|
439
373
|
return "RelayModernEnvironment(".concat((_this$configName = this.configName) !== null && _this$configName !== void 0 ? _this$configName : '', ")");
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* Wraps the network with logging to ensure that network requests are
|
|
443
|
-
* always logged. Relying on each network callsite to be wrapped is
|
|
444
|
-
* untenable and will eventually lead to holes in the logging.
|
|
445
|
-
*/
|
|
446
|
-
;
|
|
374
|
+
};
|
|
447
375
|
|
|
448
|
-
_proto.
|
|
449
|
-
var
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
var logRequestInfo = function logRequestInfo(info) {
|
|
493
|
-
log({
|
|
494
|
-
name: 'network.info',
|
|
495
|
-
transactionID: transactionID,
|
|
496
|
-
info: info
|
|
497
|
-
});
|
|
498
|
-
};
|
|
499
|
-
|
|
500
|
-
return network.execute(params, variables, cacheConfig, uploadables, logRequestInfo)["do"](logObserver);
|
|
501
|
-
}
|
|
502
|
-
};
|
|
376
|
+
_proto._execute = function _execute(_ref4) {
|
|
377
|
+
var _this9 = this;
|
|
378
|
+
|
|
379
|
+
var createSource = _ref4.createSource,
|
|
380
|
+
isClientPayload = _ref4.isClientPayload,
|
|
381
|
+
operation = _ref4.operation,
|
|
382
|
+
optimisticConfig = _ref4.optimisticConfig,
|
|
383
|
+
updater = _ref4.updater;
|
|
384
|
+
var publishQueue = this._publishQueue;
|
|
385
|
+
var store = this._store;
|
|
386
|
+
return RelayObservable.create(function (sink) {
|
|
387
|
+
var executor = OperationExecutor.execute({
|
|
388
|
+
actorIdentifier: INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE,
|
|
389
|
+
getDataID: _this9._getDataID,
|
|
390
|
+
isClientPayload: isClientPayload,
|
|
391
|
+
log: _this9.__log,
|
|
392
|
+
operation: operation,
|
|
393
|
+
operationExecutions: _this9._operationExecutions,
|
|
394
|
+
operationLoader: _this9._operationLoader,
|
|
395
|
+
operationTracker: _this9._operationTracker,
|
|
396
|
+
optimisticConfig: optimisticConfig,
|
|
397
|
+
getPublishQueue: function getPublishQueue(actorIdentifier) {
|
|
398
|
+
assertInternalActorIndentifier(actorIdentifier);
|
|
399
|
+
return publishQueue;
|
|
400
|
+
},
|
|
401
|
+
reactFlightPayloadDeserializer: _this9._reactFlightPayloadDeserializer,
|
|
402
|
+
reactFlightServerErrorHandler: _this9._reactFlightServerErrorHandler,
|
|
403
|
+
scheduler: _this9._scheduler,
|
|
404
|
+
shouldProcessClientComponents: _this9._shouldProcessClientComponents,
|
|
405
|
+
sink: sink,
|
|
406
|
+
// NOTE: Some product tests expect `Network.execute` to be called only
|
|
407
|
+
// when the Observable is executed.
|
|
408
|
+
source: createSource(),
|
|
409
|
+
getStore: function getStore(actorIdentifier) {
|
|
410
|
+
assertInternalActorIndentifier(actorIdentifier);
|
|
411
|
+
return store;
|
|
412
|
+
},
|
|
413
|
+
treatMissingFieldsAsNull: _this9._treatMissingFieldsAsNull,
|
|
414
|
+
updater: updater
|
|
415
|
+
});
|
|
416
|
+
return function () {
|
|
417
|
+
return executor.cancel();
|
|
418
|
+
};
|
|
419
|
+
});
|
|
503
420
|
};
|
|
504
421
|
|
|
505
422
|
return RelayModernEnvironment;
|