relay-runtime 11.0.2 → 13.0.0-rc.2
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/README.md +67 -0
- package/handlers/RelayDefaultHandlerProvider.js.flow +3 -3
- package/handlers/connection/ConnectionHandler.js.flow +9 -18
- package/handlers/connection/ConnectionInterface.js.flow +1 -1
- package/handlers/connection/MutationHandlers.js.flow +8 -12
- package/index.js +1 -1
- package/index.js.flow +57 -35
- package/lib/handlers/RelayDefaultHandlerProvider.js +1 -1
- package/lib/handlers/connection/ConnectionHandler.js +13 -19
- package/lib/handlers/connection/ConnectionInterface.js +1 -1
- package/lib/handlers/connection/MutationHandlers.js +4 -7
- package/lib/index.js +59 -44
- package/lib/multi-actor-environment/ActorIdentifier.js +12 -2
- package/lib/multi-actor-environment/ActorSpecificEnvironment.js +64 -20
- package/lib/multi-actor-environment/ActorUtils.js +27 -0
- package/lib/multi-actor-environment/MultiActorEnvironment.js +324 -61
- package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +1 -1
- package/lib/multi-actor-environment/index.js +6 -2
- package/lib/mutations/RelayDeclarativeMutationConfig.js +5 -2
- package/lib/mutations/RelayRecordProxy.js +4 -3
- package/lib/mutations/RelayRecordSourceMutator.js +4 -3
- package/lib/mutations/RelayRecordSourceProxy.js +13 -5
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +19 -6
- package/lib/mutations/applyOptimisticMutation.js +7 -7
- package/lib/mutations/commitLocalUpdate.js +1 -1
- package/lib/mutations/commitMutation.js +15 -11
- package/lib/mutations/readUpdatableQuery_EXPERIMENTAL.js +242 -0
- package/lib/mutations/validateMutation.js +11 -6
- package/lib/network/ConvertToExecuteFunction.js +3 -2
- package/lib/network/RelayNetwork.js +4 -3
- package/lib/network/RelayNetworkTypes.js +1 -1
- package/lib/network/RelayObservable.js +1 -1
- package/lib/network/RelayQueryResponseCache.js +22 -6
- package/lib/network/wrapNetworkWithLogObserver.js +79 -0
- package/lib/query/GraphQLTag.js +3 -2
- package/lib/query/PreloadableQueryRegistry.js +1 -1
- package/lib/query/fetchQuery.js +7 -6
- package/lib/query/fetchQueryInternal.js +1 -1
- package/lib/query/fetchQuery_DEPRECATED.js +3 -2
- package/lib/store/ClientID.js +8 -2
- package/lib/store/DataChecker.js +124 -55
- package/lib/store/OperationExecutor.js +489 -215
- package/lib/store/RelayConcreteVariables.js +27 -9
- package/lib/store/RelayExperimentalGraphResponseHandler.js +153 -0
- package/lib/store/RelayExperimentalGraphResponseTransform.js +391 -0
- package/lib/store/RelayModernEnvironment.js +100 -120
- package/lib/store/RelayModernFragmentSpecResolver.js +53 -27
- package/lib/store/RelayModernOperationDescriptor.js +3 -2
- package/lib/store/RelayModernRecord.js +48 -13
- package/lib/store/RelayModernSelector.js +15 -9
- package/lib/store/RelayModernStore.js +56 -23
- package/lib/store/RelayOperationTracker.js +34 -24
- package/lib/store/RelayOptimisticRecordSource.js +1 -1
- package/lib/store/RelayPublishQueue.js +35 -11
- package/lib/store/RelayReader.js +257 -72
- package/lib/store/RelayRecordSource.js +88 -4
- package/lib/store/RelayRecordState.js +1 -1
- package/lib/store/RelayReferenceMarker.js +34 -22
- package/lib/store/RelayResponseNormalizer.js +172 -96
- package/lib/store/RelayStoreReactFlightUtils.js +5 -11
- package/lib/store/RelayStoreSubscriptions.js +15 -10
- package/lib/store/RelayStoreTypes.js +1 -1
- package/lib/store/RelayStoreUtils.js +13 -8
- package/lib/store/ResolverCache.js +213 -0
- package/lib/store/ResolverFragments.js +10 -6
- package/lib/store/StoreInspector.js +1 -1
- package/lib/store/TypeID.js +1 -1
- package/lib/store/ViewerPattern.js +1 -1
- package/lib/store/cloneRelayHandleSourceField.js +6 -5
- package/lib/store/cloneRelayScalarHandleSourceField.js +6 -5
- package/lib/store/createFragmentSpecResolver.js +1 -1
- package/lib/store/createRelayContext.js +5 -3
- package/lib/store/defaultGetDataID.js +1 -1
- package/lib/store/defaultRequiredFieldLogger.js +1 -1
- package/lib/store/hasOverlappingIDs.js +1 -1
- package/lib/store/isRelayModernEnvironment.js +1 -1
- package/lib/store/normalizeRelayPayload.js +1 -1
- package/lib/store/readInlineData.js +7 -3
- package/lib/subscription/requestSubscription.js +32 -34
- package/lib/util/JSResourceTypes.flow.js +1 -1
- package/lib/util/NormalizationNode.js +1 -1
- package/lib/util/ReaderNode.js +1 -1
- package/lib/util/RelayConcreteNode.js +3 -1
- package/lib/util/RelayDefaultHandleKey.js +1 -1
- package/lib/util/RelayError.js +1 -1
- package/lib/util/RelayFeatureFlags.js +10 -7
- package/lib/util/RelayProfiler.js +1 -1
- package/lib/util/RelayReplaySubject.js +22 -7
- package/lib/util/RelayRuntimeTypes.js +1 -7
- package/lib/util/StringInterner.js +71 -0
- package/lib/util/createPayloadFor3DField.js +1 -1
- package/lib/util/deepFreeze.js +1 -1
- package/lib/util/generateID.js +1 -1
- package/lib/util/getAllRootVariables.js +29 -0
- package/lib/util/getFragmentIdentifier.js +16 -8
- package/lib/util/getOperation.js +3 -2
- 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 +3 -3
- package/lib/util/getRequestIdentifier.js +3 -3
- package/lib/util/getValueAtPath.js +51 -0
- package/lib/util/isEmptyObject.js +2 -2
- package/lib/util/isPromise.js +1 -1
- package/lib/util/isScalarAndEqual.js +1 -1
- package/lib/util/recycleNodesInto.js +1 -1
- package/lib/util/registerEnvironmentWithDevTools.js +26 -0
- package/lib/util/reportMissingRequiredFields.js +1 -1
- package/lib/util/resolveImmediate.js +1 -1
- package/lib/util/stableCopy.js +1 -1
- package/lib/util/withDuration.js +31 -0
- package/multi-actor-environment/ActorIdentifier.js.flow +18 -2
- package/multi-actor-environment/ActorSpecificEnvironment.js.flow +94 -58
- package/multi-actor-environment/ActorUtils.js.flow +33 -0
- package/multi-actor-environment/MultiActorEnvironment.js.flow +366 -93
- package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +88 -23
- package/multi-actor-environment/index.js.flow +3 -1
- package/mutations/RelayDeclarativeMutationConfig.js.flow +33 -27
- package/mutations/RelayRecordProxy.js.flow +5 -6
- package/mutations/RelayRecordSourceMutator.js.flow +5 -7
- package/mutations/RelayRecordSourceProxy.js.flow +20 -11
- package/mutations/RelayRecordSourceSelectorProxy.js.flow +23 -8
- package/mutations/applyOptimisticMutation.js.flow +14 -15
- package/mutations/commitLocalUpdate.js.flow +2 -2
- package/mutations/commitMutation.js.flow +36 -47
- package/mutations/readUpdatableQuery_EXPERIMENTAL.js.flow +318 -0
- package/mutations/validateMutation.js.flow +27 -17
- package/network/ConvertToExecuteFunction.js.flow +3 -3
- package/network/RelayNetwork.js.flow +5 -6
- package/network/RelayNetworkTypes.js.flow +1 -1
- package/network/RelayObservable.js.flow +2 -2
- package/network/RelayQueryResponseCache.js.flow +35 -22
- package/network/wrapNetworkWithLogObserver.js.flow +99 -0
- package/package.json +2 -2
- package/query/GraphQLTag.js.flow +11 -11
- package/query/PreloadableQueryRegistry.js.flow +5 -3
- package/query/fetchQuery.js.flow +19 -19
- package/query/fetchQueryInternal.js.flow +7 -10
- package/query/fetchQuery_DEPRECATED.js.flow +7 -7
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/ClientID.js.flow +15 -4
- package/store/DataChecker.js.flow +142 -60
- package/store/OperationExecutor.js.flow +575 -320
- package/store/RelayConcreteVariables.js.flow +28 -9
- package/store/RelayExperimentalGraphResponseHandler.js.flow +121 -0
- package/store/RelayExperimentalGraphResponseTransform.js.flow +470 -0
- package/store/RelayModernEnvironment.js.flow +91 -115
- package/store/RelayModernFragmentSpecResolver.js.flow +56 -32
- package/store/RelayModernOperationDescriptor.js.flow +13 -8
- package/store/RelayModernRecord.js.flow +68 -12
- package/store/RelayModernSelector.js.flow +25 -15
- package/store/RelayModernStore.js.flow +67 -32
- package/store/RelayOperationTracker.js.flow +60 -44
- package/store/RelayOptimisticRecordSource.js.flow +3 -3
- package/store/RelayPublishQueue.js.flow +74 -32
- package/store/RelayReader.js.flow +319 -100
- package/store/RelayRecordSource.js.flow +73 -7
- package/store/RelayRecordState.js.flow +1 -1
- package/store/RelayReferenceMarker.js.flow +41 -27
- package/store/RelayResponseNormalizer.js.flow +204 -86
- package/store/RelayStoreReactFlightUtils.js.flow +5 -12
- package/store/RelayStoreSubscriptions.js.flow +20 -12
- package/store/RelayStoreTypes.js.flow +200 -41
- package/store/RelayStoreUtils.js.flow +25 -12
- package/store/ResolverCache.js.flow +249 -0
- package/store/ResolverFragments.js.flow +16 -20
- package/store/StoreInspector.js.flow +3 -3
- package/store/TypeID.js.flow +2 -2
- package/store/ViewerPattern.js.flow +3 -3
- package/store/cloneRelayHandleSourceField.js.flow +6 -7
- package/store/cloneRelayScalarHandleSourceField.js.flow +6 -7
- package/store/createFragmentSpecResolver.js.flow +4 -5
- package/store/createRelayContext.js.flow +4 -4
- package/store/defaultGetDataID.js.flow +1 -1
- package/store/defaultRequiredFieldLogger.js.flow +1 -1
- package/store/hasOverlappingIDs.js.flow +1 -1
- package/store/isRelayModernEnvironment.js.flow +1 -1
- package/store/normalizeRelayPayload.js.flow +7 -8
- package/store/readInlineData.js.flow +8 -9
- package/subscription/requestSubscription.js.flow +55 -51
- package/util/JSResourceTypes.flow.js.flow +1 -1
- package/util/NormalizationNode.js.flow +11 -4
- package/util/ReaderNode.js.flow +25 -2
- package/util/RelayConcreteNode.js.flow +5 -1
- package/util/RelayDefaultHandleKey.js.flow +1 -1
- package/util/RelayError.js.flow +1 -1
- package/util/RelayFeatureFlags.js.flow +23 -15
- package/util/RelayProfiler.js.flow +1 -1
- package/util/RelayReplaySubject.js.flow +10 -10
- package/util/RelayRuntimeTypes.js.flow +70 -3
- package/util/StringInterner.js.flow +69 -0
- package/util/createPayloadFor3DField.js.flow +4 -4
- package/util/deepFreeze.js.flow +1 -1
- package/util/generateID.js.flow +1 -1
- package/util/getAllRootVariables.js.flow +36 -0
- package/util/getFragmentIdentifier.js.flow +28 -16
- package/util/getOperation.js.flow +3 -3
- package/util/getPaginationMetadata.js.flow +69 -0
- package/util/getPaginationVariables.js.flow +108 -0
- package/util/getPendingOperationsForFragment.js.flow +62 -0
- package/util/getRefetchMetadata.js.flow +76 -0
- package/util/getRelayHandleKey.js.flow +2 -3
- package/util/getRequestIdentifier.js.flow +4 -4
- package/util/getValueAtPath.js.flow +46 -0
- package/util/isEmptyObject.js.flow +2 -1
- package/util/isPromise.js.flow +1 -1
- package/util/isScalarAndEqual.js.flow +1 -1
- package/util/recycleNodesInto.js.flow +1 -1
- package/util/registerEnvironmentWithDevTools.js.flow +33 -0
- package/util/reportMissingRequiredFields.js.flow +1 -1
- package/util/resolveImmediate.js.flow +2 -2
- package/util/stableCopy.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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and 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.
|
|
@@ -10,42 +10,54 @@
|
|
|
10
10
|
*/
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var RelayDefaultHandlerProvider = require('../handlers/RelayDefaultHandlerProvider');
|
|
20
20
|
|
|
21
21
|
var RelayObservable = require('../network/RelayObservable');
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var defaultGetDataID = require('../store/defaultGetDataID');
|
|
24
24
|
|
|
25
|
-
var
|
|
25
|
+
var defaultRequiredFieldLogger = require('../store/defaultRequiredFieldLogger');
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var OperationExecutor = require('../store/OperationExecutor');
|
|
28
|
+
|
|
29
|
+
var RelayModernStore = require('../store/RelayModernStore');
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
var RelayRecordSource = require('../store/RelayRecordSource');
|
|
32
|
+
|
|
33
|
+
var ActorSpecificEnvironment = require('./ActorSpecificEnvironment');
|
|
32
34
|
|
|
33
35
|
var MultiActorEnvironment = /*#__PURE__*/function () {
|
|
34
36
|
function MultiActorEnvironment(config) {
|
|
35
|
-
var _config$getDataID, _config$treatMissingF;
|
|
37
|
+
var _config$getDataID, _config$logFn, _config$requiredField, _config$treatMissingF, _config$isServer, _config$defaultRender;
|
|
36
38
|
|
|
37
39
|
this._actorEnvironments = new Map();
|
|
40
|
+
this._operationLoader = config.operationLoader;
|
|
38
41
|
this._createNetworkForActor = config.createNetworkForActor;
|
|
42
|
+
this._scheduler = config.scheduler;
|
|
39
43
|
this._getDataID = (_config$getDataID = config.getDataID) !== null && _config$getDataID !== void 0 ? _config$getDataID : defaultGetDataID;
|
|
40
44
|
this._handlerProvider = config.handlerProvider ? config.handlerProvider : RelayDefaultHandlerProvider;
|
|
41
|
-
this._logFn = config.logFn;
|
|
45
|
+
this._logFn = (_config$logFn = config.logFn) !== null && _config$logFn !== void 0 ? _config$logFn : emptyFunction;
|
|
42
46
|
this._operationExecutions = new Map();
|
|
43
|
-
this._requiredFieldLogger = config.requiredFieldLogger;
|
|
47
|
+
this._requiredFieldLogger = (_config$requiredField = config.requiredFieldLogger) !== null && _config$requiredField !== void 0 ? _config$requiredField : defaultRequiredFieldLogger;
|
|
48
|
+
this._shouldProcessClientComponents = config.shouldProcessClientComponents;
|
|
44
49
|
this._treatMissingFieldsAsNull = (_config$treatMissingF = config.treatMissingFieldsAsNull) !== null && _config$treatMissingF !== void 0 ? _config$treatMissingF : false;
|
|
50
|
+
this._isServer = (_config$isServer = config.isServer) !== null && _config$isServer !== void 0 ? _config$isServer : false;
|
|
51
|
+
this._missingFieldHandlers = config.missingFieldHandlers;
|
|
52
|
+
this._createStoreForActor = config.createStoreForActor;
|
|
53
|
+
this._reactFlightPayloadDeserializer = config.reactFlightPayloadDeserializer;
|
|
54
|
+
this._reactFlightServerErrorHandler = config.reactFlightServerErrorHandler;
|
|
55
|
+
this._createConfigNameForActor = config.createConfigNameForActor;
|
|
56
|
+
this._defaultRenderPolicy = (_config$defaultRender = config.defaultRenderPolicy) !== null && _config$defaultRender !== void 0 ? _config$defaultRender : 'partial';
|
|
45
57
|
}
|
|
46
58
|
/**
|
|
47
|
-
* This method will create an actor
|
|
48
|
-
* and store it in the internal maps. If will return a
|
|
59
|
+
* This method will create an actor specific environment. It will create a new instance
|
|
60
|
+
* and store it in the internal maps. If will return a memoized version
|
|
49
61
|
* of the environment if we already created one for actor.
|
|
50
62
|
*/
|
|
51
63
|
|
|
@@ -57,12 +69,15 @@ var MultiActorEnvironment = /*#__PURE__*/function () {
|
|
|
57
69
|
|
|
58
70
|
if (environment == null) {
|
|
59
71
|
var newEnvironment = new ActorSpecificEnvironment({
|
|
72
|
+
configName: this._createConfigNameForActor ? this._createConfigNameForActor(actorIdentifier) : null,
|
|
60
73
|
actorIdentifier: actorIdentifier,
|
|
61
74
|
multiActorEnvironment: this,
|
|
62
75
|
logFn: this._logFn,
|
|
63
76
|
requiredFieldLogger: this._requiredFieldLogger,
|
|
64
|
-
store: new RelayModernStore(RelayRecordSource.create()),
|
|
65
|
-
network: this._createNetworkForActor(actorIdentifier)
|
|
77
|
+
store: this._createStoreForActor != null ? this._createStoreForActor(actorIdentifier) : new RelayModernStore(RelayRecordSource.create()),
|
|
78
|
+
network: this._createNetworkForActor(actorIdentifier),
|
|
79
|
+
handlerProvider: this._handlerProvider,
|
|
80
|
+
defaultRenderPolicy: this._defaultRenderPolicy
|
|
66
81
|
});
|
|
67
82
|
|
|
68
83
|
this._actorEnvironments.set(actorIdentifier, newEnvironment);
|
|
@@ -73,64 +88,288 @@ var MultiActorEnvironment = /*#__PURE__*/function () {
|
|
|
73
88
|
}
|
|
74
89
|
};
|
|
75
90
|
|
|
76
|
-
_proto.check = function check(
|
|
77
|
-
|
|
91
|
+
_proto.check = function check(actorEnvironment, operation) {
|
|
92
|
+
var _this = this;
|
|
93
|
+
|
|
94
|
+
if (this._missingFieldHandlers == null || this._missingFieldHandlers.length === 0) {
|
|
95
|
+
return actorEnvironment.getStore().check(operation, {
|
|
96
|
+
handlers: [],
|
|
97
|
+
defaultActorIdentifier: actorEnvironment.actorIdentifier,
|
|
98
|
+
getSourceForActor: function getSourceForActor(actorIdentifier) {
|
|
99
|
+
return _this.forActor(actorIdentifier).getStore().getSource();
|
|
100
|
+
},
|
|
101
|
+
getTargetForActor: function getTargetForActor() {
|
|
102
|
+
return RelayRecordSource.create();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return this._checkSelectorAndHandleMissingFields(actorEnvironment, operation, this._missingFieldHandlers);
|
|
78
108
|
};
|
|
79
109
|
|
|
80
|
-
_proto.
|
|
81
|
-
|
|
110
|
+
_proto._checkSelectorAndHandleMissingFields = function _checkSelectorAndHandleMissingFields(actorEnvironment, operation, handlers) {
|
|
111
|
+
var _this2 = this;
|
|
112
|
+
|
|
113
|
+
var targets = new Map([[actorEnvironment.actorIdentifier, RelayRecordSource.create()]]);
|
|
114
|
+
var result = actorEnvironment.getStore().check(operation, {
|
|
115
|
+
handlers: handlers,
|
|
116
|
+
defaultActorIdentifier: actorEnvironment.actorIdentifier,
|
|
117
|
+
getSourceForActor: function getSourceForActor(actorIdentifier) {
|
|
118
|
+
return _this2.forActor(actorIdentifier).getStore().getSource();
|
|
119
|
+
},
|
|
120
|
+
getTargetForActor: function getTargetForActor(actorIdentifier) {
|
|
121
|
+
var target = targets.get(actorIdentifier);
|
|
122
|
+
|
|
123
|
+
if (target == null) {
|
|
124
|
+
target = RelayRecordSource.create();
|
|
125
|
+
targets.set(actorIdentifier, target);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return target;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
var _iterator = (0, _createForOfIteratorHelper2["default"])(targets),
|
|
133
|
+
_step;
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
var _loop = function _loop() {
|
|
137
|
+
var _step$value = _step.value,
|
|
138
|
+
actorIdentifier = _step$value[0],
|
|
139
|
+
target = _step$value[1];
|
|
140
|
+
|
|
141
|
+
if (target.size() > 0) {
|
|
142
|
+
_this2._scheduleUpdates(function () {
|
|
143
|
+
var publishQueue = _this2.forActor(actorIdentifier).getPublishQueue();
|
|
144
|
+
|
|
145
|
+
publishQueue.commitSource(target);
|
|
146
|
+
publishQueue.run();
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
152
|
+
_loop();
|
|
153
|
+
}
|
|
154
|
+
} catch (err) {
|
|
155
|
+
_iterator.e(err);
|
|
156
|
+
} finally {
|
|
157
|
+
_iterator.f();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return result;
|
|
82
161
|
};
|
|
83
162
|
|
|
84
|
-
_proto.
|
|
85
|
-
|
|
163
|
+
_proto.subscribe = function subscribe(actorEnvironment, snapshot, callback) {
|
|
164
|
+
// TODO: make actor aware
|
|
165
|
+
return actorEnvironment.getStore().subscribe(snapshot, callback);
|
|
86
166
|
};
|
|
87
167
|
|
|
88
|
-
_proto.
|
|
89
|
-
|
|
168
|
+
_proto.retain = function retain(actorEnvironment, operation) {
|
|
169
|
+
// TODO: make actor aware
|
|
170
|
+
return actorEnvironment.getStore().retain(operation);
|
|
90
171
|
};
|
|
91
172
|
|
|
92
|
-
_proto.
|
|
93
|
-
|
|
173
|
+
_proto.applyUpdate = function applyUpdate(actorEnvironment, optimisticUpdate) {
|
|
174
|
+
var _this3 = this;
|
|
175
|
+
|
|
176
|
+
var publishQueue = actorEnvironment.getPublishQueue();
|
|
177
|
+
|
|
178
|
+
var dispose = function dispose() {
|
|
179
|
+
_this3._scheduleUpdates(function () {
|
|
180
|
+
publishQueue.revertUpdate(optimisticUpdate);
|
|
181
|
+
publishQueue.run();
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
this._scheduleUpdates(function () {
|
|
186
|
+
publishQueue.applyUpdate(optimisticUpdate);
|
|
187
|
+
publishQueue.run();
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
dispose: dispose
|
|
192
|
+
};
|
|
94
193
|
};
|
|
95
194
|
|
|
96
|
-
_proto.
|
|
97
|
-
|
|
195
|
+
_proto.revertUpdate = function revertUpdate(actorEnvironment, update) {
|
|
196
|
+
var publishQueue = actorEnvironment.getPublishQueue();
|
|
197
|
+
|
|
198
|
+
this._scheduleUpdates(function () {
|
|
199
|
+
publishQueue.revertUpdate(update);
|
|
200
|
+
publishQueue.run();
|
|
201
|
+
});
|
|
98
202
|
};
|
|
99
203
|
|
|
100
|
-
_proto.
|
|
101
|
-
|
|
204
|
+
_proto.replaceUpdate = function replaceUpdate(actorEnvironment, update, replacement) {
|
|
205
|
+
var publishQueue = actorEnvironment.getPublishQueue();
|
|
206
|
+
|
|
207
|
+
this._scheduleUpdates(function () {
|
|
208
|
+
publishQueue.revertUpdate(update);
|
|
209
|
+
publishQueue.applyUpdate(replacement);
|
|
210
|
+
publishQueue.run();
|
|
211
|
+
});
|
|
102
212
|
};
|
|
103
213
|
|
|
104
|
-
_proto.
|
|
105
|
-
|
|
214
|
+
_proto.applyMutation = function applyMutation(actorEnvironment, optimisticConfig) {
|
|
215
|
+
var subscription = this._execute(actorEnvironment, {
|
|
216
|
+
createSource: function createSource() {
|
|
217
|
+
return RelayObservable.create(function (_sink) {});
|
|
218
|
+
},
|
|
219
|
+
isClientPayload: false,
|
|
220
|
+
operation: optimisticConfig.operation,
|
|
221
|
+
optimisticConfig: optimisticConfig,
|
|
222
|
+
updater: null
|
|
223
|
+
}).subscribe({});
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
dispose: function dispose() {
|
|
227
|
+
return subscription.unsubscribe();
|
|
228
|
+
}
|
|
229
|
+
};
|
|
106
230
|
};
|
|
107
231
|
|
|
108
|
-
_proto.
|
|
109
|
-
var
|
|
232
|
+
_proto.commitUpdate = function commitUpdate(actorEnvironment, updater) {
|
|
233
|
+
var publishQueue = actorEnvironment.getPublishQueue();
|
|
110
234
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
235
|
+
this._scheduleUpdates(function () {
|
|
236
|
+
publishQueue.commitUpdate(updater);
|
|
237
|
+
publishQueue.run();
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
_proto.commitPayload = function commitPayload(actorEnvironment, operationDescriptor, payload) {
|
|
242
|
+
this._execute(actorEnvironment, {
|
|
243
|
+
createSource: function createSource() {
|
|
244
|
+
return RelayObservable.from({
|
|
245
|
+
data: payload
|
|
246
|
+
});
|
|
247
|
+
},
|
|
248
|
+
isClientPayload: true,
|
|
249
|
+
operation: operationDescriptor,
|
|
250
|
+
optimisticConfig: null,
|
|
251
|
+
updater: null
|
|
252
|
+
}).subscribe({});
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
_proto.lookup = function lookup(actorEnvironment, selector) {
|
|
256
|
+
// TODO: make actor aware
|
|
257
|
+
return actorEnvironment.getStore().lookup(selector);
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
_proto.execute = function execute(actorEnvironment, _ref) {
|
|
261
|
+
var operation = _ref.operation;
|
|
262
|
+
return this._execute(actorEnvironment, {
|
|
263
|
+
createSource: function createSource() {
|
|
264
|
+
return actorEnvironment.getNetwork().execute(operation.request.node.params, operation.request.variables, operation.request.cacheConfig || {}, null);
|
|
265
|
+
},
|
|
266
|
+
isClientPayload: false,
|
|
267
|
+
operation: operation,
|
|
268
|
+
optimisticConfig: null,
|
|
269
|
+
updater: null
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
_proto.executeSubscription = function executeSubscription(actorEnvironment, _ref2) {
|
|
274
|
+
var operation = _ref2.operation,
|
|
275
|
+
updater = _ref2.updater;
|
|
276
|
+
return this._execute(actorEnvironment, {
|
|
277
|
+
createSource: function createSource() {
|
|
278
|
+
return actorEnvironment.getNetwork().execute(operation.request.node.params, operation.request.variables, operation.request.cacheConfig || {}, null);
|
|
279
|
+
},
|
|
280
|
+
isClientPayload: false,
|
|
281
|
+
operation: operation,
|
|
282
|
+
optimisticConfig: null,
|
|
283
|
+
updater: updater
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
_proto.executeMutation = function executeMutation(actorEnvironment, _ref3) {
|
|
288
|
+
var operation = _ref3.operation,
|
|
289
|
+
optimisticResponse = _ref3.optimisticResponse,
|
|
290
|
+
optimisticUpdater = _ref3.optimisticUpdater,
|
|
291
|
+
updater = _ref3.updater,
|
|
292
|
+
uploadables = _ref3.uploadables;
|
|
293
|
+
var optimisticConfig;
|
|
294
|
+
|
|
295
|
+
if (optimisticResponse || optimisticUpdater) {
|
|
296
|
+
optimisticConfig = {
|
|
297
|
+
operation: operation,
|
|
298
|
+
response: optimisticResponse,
|
|
299
|
+
updater: optimisticUpdater
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return this._execute(actorEnvironment, {
|
|
304
|
+
createSource: function createSource() {
|
|
305
|
+
return actorEnvironment.getNetwork().execute(operation.request.node.params, operation.request.variables, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, operation.request.cacheConfig), {}, {
|
|
306
|
+
force: true
|
|
307
|
+
}), uploadables);
|
|
308
|
+
},
|
|
309
|
+
isClientPayload: false,
|
|
310
|
+
operation: operation,
|
|
311
|
+
optimisticConfig: optimisticConfig,
|
|
312
|
+
updater: updater
|
|
313
|
+
});
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
_proto.executeWithSource = function executeWithSource(actorEnvironment, config) {
|
|
317
|
+
return this._execute(actorEnvironment, {
|
|
318
|
+
createSource: function createSource() {
|
|
319
|
+
return config.source;
|
|
320
|
+
},
|
|
321
|
+
isClientPayload: false,
|
|
322
|
+
operation: config.operation,
|
|
323
|
+
optimisticConfig: null,
|
|
324
|
+
updater: null
|
|
325
|
+
});
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
_proto.isRequestActive = function isRequestActive(_actorEnvironment, requestIdentifier) {
|
|
329
|
+
var activeState = this._operationExecutions.get(requestIdentifier);
|
|
330
|
+
|
|
331
|
+
return activeState === 'active';
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
_proto.isServer = function isServer() {
|
|
335
|
+
return this._isServer;
|
|
336
|
+
};
|
|
115
337
|
|
|
116
|
-
|
|
338
|
+
_proto._execute = function _execute(actorEnvironment, _ref4) {
|
|
339
|
+
var _this4 = this;
|
|
340
|
+
|
|
341
|
+
var createSource = _ref4.createSource,
|
|
342
|
+
isClientPayload = _ref4.isClientPayload,
|
|
343
|
+
operation = _ref4.operation,
|
|
344
|
+
optimisticConfig = _ref4.optimisticConfig,
|
|
345
|
+
updater = _ref4.updater;
|
|
346
|
+
return RelayObservable.create(function (sink) {
|
|
117
347
|
var executor = OperationExecutor.execute({
|
|
348
|
+
actorIdentifier: actorEnvironment.actorIdentifier,
|
|
349
|
+
getDataID: _this4._getDataID,
|
|
350
|
+
isClientPayload: isClientPayload,
|
|
118
351
|
operation: operation,
|
|
119
|
-
operationExecutions:
|
|
120
|
-
operationLoader:
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
352
|
+
operationExecutions: _this4._operationExecutions,
|
|
353
|
+
operationLoader: _this4._operationLoader,
|
|
354
|
+
operationTracker: actorEnvironment.getOperationTracker(),
|
|
355
|
+
optimisticConfig: optimisticConfig,
|
|
356
|
+
getPublishQueue: function getPublishQueue(actorIdentifier) {
|
|
357
|
+
return _this4.forActor(actorIdentifier).getPublishQueue();
|
|
358
|
+
},
|
|
359
|
+
reactFlightPayloadDeserializer: _this4._reactFlightPayloadDeserializer,
|
|
360
|
+
reactFlightServerErrorHandler: _this4._reactFlightServerErrorHandler,
|
|
361
|
+
scheduler: _this4._scheduler,
|
|
362
|
+
shouldProcessClientComponents: _this4._shouldProcessClientComponents,
|
|
126
363
|
sink: sink,
|
|
127
|
-
|
|
128
|
-
|
|
364
|
+
// NOTE: Some product tests expect `Network.execute` to be called only
|
|
365
|
+
// when the Observable is executed.
|
|
366
|
+
source: createSource(),
|
|
367
|
+
getStore: function getStore(actorIdentifier) {
|
|
368
|
+
return _this4.forActor(actorIdentifier).getStore();
|
|
369
|
+
},
|
|
370
|
+
treatMissingFieldsAsNull: _this4._treatMissingFieldsAsNull,
|
|
129
371
|
updater: updater,
|
|
130
|
-
|
|
131
|
-
getDataID: _this._getDataID,
|
|
132
|
-
treatMissingFieldsAsNull: _this._treatMissingFieldsAsNull,
|
|
133
|
-
shouldProcessClientComponents: false
|
|
372
|
+
log: _this4._logFn
|
|
134
373
|
});
|
|
135
374
|
return function () {
|
|
136
375
|
return executor.cancel();
|
|
@@ -138,19 +377,43 @@ var MultiActorEnvironment = /*#__PURE__*/function () {
|
|
|
138
377
|
});
|
|
139
378
|
};
|
|
140
379
|
|
|
141
|
-
_proto.
|
|
142
|
-
|
|
143
|
-
};
|
|
380
|
+
_proto._scheduleUpdates = function _scheduleUpdates(task) {
|
|
381
|
+
var scheduler = this._scheduler;
|
|
144
382
|
|
|
145
|
-
|
|
146
|
-
|
|
383
|
+
if (scheduler != null) {
|
|
384
|
+
scheduler.schedule(task);
|
|
385
|
+
} else {
|
|
386
|
+
task();
|
|
387
|
+
}
|
|
147
388
|
};
|
|
148
389
|
|
|
149
|
-
_proto.
|
|
150
|
-
|
|
390
|
+
_proto.commitMultiActorUpdate = function commitMultiActorUpdate(updater) {
|
|
391
|
+
var _iterator2 = (0, _createForOfIteratorHelper2["default"])(this._actorEnvironments),
|
|
392
|
+
_step2;
|
|
393
|
+
|
|
394
|
+
try {
|
|
395
|
+
var _loop2 = function _loop2() {
|
|
396
|
+
var _step2$value = _step2.value,
|
|
397
|
+
actorIdentifier = _step2$value[0],
|
|
398
|
+
environment = _step2$value[1];
|
|
399
|
+
environment.commitUpdate(function (storeProxy) {
|
|
400
|
+
updater(actorIdentifier, environment, storeProxy);
|
|
401
|
+
});
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
405
|
+
_loop2();
|
|
406
|
+
}
|
|
407
|
+
} catch (err) {
|
|
408
|
+
_iterator2.e(err);
|
|
409
|
+
} finally {
|
|
410
|
+
_iterator2.f();
|
|
411
|
+
}
|
|
151
412
|
};
|
|
152
413
|
|
|
153
414
|
return MultiActorEnvironment;
|
|
154
415
|
}();
|
|
155
416
|
|
|
417
|
+
function emptyFunction() {}
|
|
418
|
+
|
|
156
419
|
module.exports = MultiActorEnvironment;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and 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.
|
|
@@ -10,8 +10,12 @@
|
|
|
10
10
|
*/
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
+
var _require = require('./ActorIdentifier'),
|
|
14
|
+
getActorIdentifier = _require.getActorIdentifier;
|
|
15
|
+
|
|
13
16
|
var MultiActorEnvironment = require('./MultiActorEnvironment');
|
|
14
17
|
|
|
15
18
|
module.exports = {
|
|
16
|
-
MultiActorEnvironment: MultiActorEnvironment
|
|
19
|
+
MultiActorEnvironment: MultiActorEnvironment,
|
|
20
|
+
getActorIdentifier: getActorIdentifier
|
|
17
21
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and 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.
|
|
@@ -201,7 +201,10 @@ function rangeDelete(config, request) {
|
|
|
201
201
|
return;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
var deleteIDs = [];
|
|
204
|
+
var deleteIDs = []; // the type of data should come from a type parameter associated with ConcreteRequest,
|
|
205
|
+
// but ConcreteRequest does not contain a type parameter. Hence, we use a FlowFixMe.
|
|
206
|
+
// $FlowFixMe[incompatible-use] see above
|
|
207
|
+
|
|
205
208
|
var deletedIDField = data[rootField];
|
|
206
209
|
|
|
207
210
|
if (deletedIDField && Array.isArray(deletedIDFieldName)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and 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.
|
|
@@ -10,20 +10,21 @@
|
|
|
10
10
|
// flowlint ambiguous-object-type:error
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
var invariant = require('invariant');
|
|
14
|
-
|
|
15
13
|
var _require = require('../store/ClientID'),
|
|
16
14
|
generateClientID = _require.generateClientID;
|
|
17
15
|
|
|
18
16
|
var _require2 = require('../store/RelayStoreUtils'),
|
|
19
17
|
getStableStorageKey = _require2.getStableStorageKey;
|
|
20
18
|
|
|
19
|
+
var invariant = require('invariant');
|
|
21
20
|
/**
|
|
22
21
|
* @internal
|
|
23
22
|
*
|
|
24
23
|
* A helper class for manipulating a given record from a record source via an
|
|
25
24
|
* imperative/OO-style API.
|
|
26
25
|
*/
|
|
26
|
+
|
|
27
|
+
|
|
27
28
|
var RelayRecordProxy = /*#__PURE__*/function () {
|
|
28
29
|
function RelayRecordProxy(source, mutator, dataID) {
|
|
29
30
|
this._dataID = dataID;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and 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.
|
|
@@ -12,11 +12,10 @@
|
|
|
12
12
|
|
|
13
13
|
var RelayModernRecord = require('../store/RelayModernRecord');
|
|
14
14
|
|
|
15
|
-
var invariant = require('invariant');
|
|
16
|
-
|
|
17
15
|
var _require = require('../store/RelayRecordState'),
|
|
18
16
|
EXISTENT = _require.EXISTENT;
|
|
19
17
|
|
|
18
|
+
var invariant = require('invariant');
|
|
20
19
|
/**
|
|
21
20
|
* @internal
|
|
22
21
|
*
|
|
@@ -29,6 +28,8 @@ var _require = require('../store/RelayRecordState'),
|
|
|
29
28
|
* - Modifications cause a fresh version of a record to be created in `sink`.
|
|
30
29
|
* These sink records contain only modified fields.
|
|
31
30
|
*/
|
|
31
|
+
|
|
32
|
+
|
|
32
33
|
var RelayRecordSourceMutator = /*#__PURE__*/function () {
|
|
33
34
|
function RelayRecordSourceMutator(base, sink) {
|
|
34
35
|
this.__sources = [sink, base];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and 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.
|
|
@@ -12,10 +12,6 @@
|
|
|
12
12
|
|
|
13
13
|
var RelayModernRecord = require('../store/RelayModernRecord');
|
|
14
14
|
|
|
15
|
-
var RelayRecordProxy = require('./RelayRecordProxy');
|
|
16
|
-
|
|
17
|
-
var invariant = require('invariant');
|
|
18
|
-
|
|
19
15
|
var _require = require('../store/RelayRecordState'),
|
|
20
16
|
EXISTENT = _require.EXISTENT,
|
|
21
17
|
NONEXISTENT = _require.NONEXISTENT;
|
|
@@ -24,11 +20,19 @@ var _require2 = require('../store/RelayStoreUtils'),
|
|
|
24
20
|
ROOT_ID = _require2.ROOT_ID,
|
|
25
21
|
ROOT_TYPE = _require2.ROOT_TYPE;
|
|
26
22
|
|
|
23
|
+
var _require3 = require('./readUpdatableQuery_EXPERIMENTAL'),
|
|
24
|
+
_readUpdatableQuery_EXPERIMENTAL = _require3.readUpdatableQuery_EXPERIMENTAL;
|
|
25
|
+
|
|
26
|
+
var RelayRecordProxy = require('./RelayRecordProxy');
|
|
27
|
+
|
|
28
|
+
var invariant = require('invariant');
|
|
27
29
|
/**
|
|
28
30
|
* @internal
|
|
29
31
|
*
|
|
30
32
|
* A helper for manipulating a `RecordSource` via an imperative/OO-style API.
|
|
31
33
|
*/
|
|
34
|
+
|
|
35
|
+
|
|
32
36
|
var RelayRecordSourceProxy = /*#__PURE__*/function () {
|
|
33
37
|
function RelayRecordSourceProxy(mutator, getDataID, handlerProvider) {
|
|
34
38
|
this.__mutator = mutator;
|
|
@@ -131,6 +135,10 @@ var RelayRecordSourceProxy = /*#__PURE__*/function () {
|
|
|
131
135
|
return this._idsMarkedForInvalidation;
|
|
132
136
|
};
|
|
133
137
|
|
|
138
|
+
_proto.readUpdatableQuery_EXPERIMENTAL = function readUpdatableQuery_EXPERIMENTAL(query, variables) {
|
|
139
|
+
return _readUpdatableQuery_EXPERIMENTAL(query, variables, this);
|
|
140
|
+
};
|
|
141
|
+
|
|
134
142
|
return RelayRecordSourceProxy;
|
|
135
143
|
}();
|
|
136
144
|
|