relay-runtime 11.0.1 → 11.0.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/index.js +1 -1
- package/index.js.flow +4 -2
- package/lib/handlers/RelayDefaultHandlerProvider.js +1 -1
- package/lib/handlers/connection/ConnectionHandler.js +1 -1
- package/lib/handlers/connection/MutationHandlers.js +1 -1
- package/lib/multi-actor-environment/ActorIdentifier.js +23 -0
- package/lib/multi-actor-environment/ActorSpecificEnvironment.js +108 -0
- package/lib/multi-actor-environment/MultiActorEnvironment.js +156 -0
- package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +11 -0
- package/lib/multi-actor-environment/index.js +17 -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 +1 -1
- package/lib/mutations/applyOptimisticMutation.js +1 -1
- package/lib/mutations/commitMutation.js +1 -1
- package/lib/network/RelayNetwork.js +1 -1
- package/lib/network/RelayQueryResponseCache.js +1 -1
- 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 +1 -1
- package/lib/store/{RelayModernQueryExecutor.js → OperationExecutor.js} +81 -37
- package/lib/store/RelayConcreteVariables.js +1 -1
- package/lib/store/RelayModernEnvironment.js +99 -144
- package/lib/store/RelayModernFragmentSpecResolver.js +1 -1
- package/lib/store/RelayModernRecord.js +1 -1
- package/lib/store/RelayModernSelector.js +1 -1
- package/lib/store/RelayModernStore.js +1 -6
- package/lib/store/RelayOperationTracker.js +1 -1
- package/lib/store/RelayPublishQueue.js +9 -5
- package/lib/store/RelayReader.js +63 -10
- package/lib/store/RelayReferenceMarker.js +1 -1
- package/lib/store/RelayResponseNormalizer.js +47 -22
- package/lib/store/RelayStoreReactFlightUtils.js +1 -1
- package/lib/store/RelayStoreUtils.js +1 -1
- 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 +1 -1
- package/lib/store/readInlineData.js +1 -1
- package/lib/subscription/requestSubscription.js +18 -7
- package/lib/util/RelayConcreteNode.js +1 -0
- package/lib/util/RelayFeatureFlags.js +3 -1
- package/lib/util/RelayProfiler.js +17 -187
- package/lib/util/RelayReplaySubject.js +1 -1
- package/lib/util/getRelayHandleKey.js +1 -1
- package/lib/util/getRequestIdentifier.js +1 -1
- package/multi-actor-environment/ActorIdentifier.js.flow +27 -0
- package/multi-actor-environment/ActorSpecificEnvironment.js.flow +189 -0
- package/multi-actor-environment/MultiActorEnvironment.js.flow +233 -0
- package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +196 -0
- package/multi-actor-environment/index.js.flow +24 -0
- package/network/RelayNetworkTypes.js.flow +5 -4
- package/package.json +3 -2
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/{RelayModernQueryExecutor.js.flow → OperationExecutor.js.flow} +82 -35
- package/store/RelayModernEnvironment.js.flow +88 -131
- package/store/RelayModernStore.js.flow +0 -5
- package/store/RelayPublishQueue.js.flow +7 -4
- package/store/RelayReader.js.flow +57 -5
- package/store/RelayResponseNormalizer.js.flow +67 -26
- package/store/RelayStoreTypes.js.flow +15 -8
- package/store/ResolverFragments.js.flow +125 -0
- package/subscription/requestSubscription.js.flow +15 -7
- package/util/ReaderNode.js.flow +14 -1
- package/util/RelayConcreteNode.js.flow +1 -0
- package/util/RelayFeatureFlags.js.flow +4 -0
- package/util/RelayProfiler.js.flow +22 -194
- package/util/RelayRuntimeTypes.js.flow +3 -1
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @emails oncall+relay
|
|
8
|
+
* @flow strict-local
|
|
9
|
+
* @format
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
const ActorSpecificEnvironment = require('./ActorSpecificEnvironment');
|
|
15
|
+
const OperationExecutor = require('../store/OperationExecutor');
|
|
16
|
+
const RelayDefaultHandlerProvider = require('../handlers/RelayDefaultHandlerProvider');
|
|
17
|
+
const RelayModernStore = require('../store/RelayModernStore');
|
|
18
|
+
const RelayObservable = require('../network/RelayObservable');
|
|
19
|
+
const RelayPublishQueue = require('../store/RelayPublishQueue');
|
|
20
|
+
const RelayRecordSource = require('../store/RelayRecordSource');
|
|
21
|
+
|
|
22
|
+
const defaultGetDataID = require('../store/defaultGetDataID');
|
|
23
|
+
|
|
24
|
+
import type {HandlerProvider} from '../handlers/RelayDefaultHandlerProvider';
|
|
25
|
+
import type {GraphQLResponse, PayloadData} from '../network/RelayNetworkTypes';
|
|
26
|
+
import type {INetwork} from '../network/RelayNetworkTypes';
|
|
27
|
+
import type {ActiveState} from '../store/OperationExecutor';
|
|
28
|
+
import type {GetDataID} from '../store/RelayResponseNormalizer';
|
|
29
|
+
import type {
|
|
30
|
+
IEnvironment,
|
|
31
|
+
OptimisticResponseConfig,
|
|
32
|
+
OptimisticUpdateFunction,
|
|
33
|
+
OperationDescriptor,
|
|
34
|
+
OperationAvailability,
|
|
35
|
+
Snapshot,
|
|
36
|
+
SelectorStoreUpdater,
|
|
37
|
+
SingularReaderSelector,
|
|
38
|
+
StoreUpdater,
|
|
39
|
+
RequiredFieldLogger,
|
|
40
|
+
ExecuteMutationConfig,
|
|
41
|
+
LogFunction,
|
|
42
|
+
} from '../store/RelayStoreTypes';
|
|
43
|
+
import type {Disposable} from '../util/RelayRuntimeTypes';
|
|
44
|
+
import type {ActorIdentifier} from './ActorIdentifier';
|
|
45
|
+
import type {
|
|
46
|
+
IActorEnvironment,
|
|
47
|
+
IMultiActorEnvironment,
|
|
48
|
+
} from './MultiActorEnvironmentTypes';
|
|
49
|
+
|
|
50
|
+
function todo(what: string) {
|
|
51
|
+
throw new Error(`Not implementd: ${what}`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type MultiActorEnvironmentConfig = $ReadOnly<{
|
|
55
|
+
createNetworkForActor: (actorIdentifier: ActorIdentifier) => INetwork,
|
|
56
|
+
getDataID?: GetDataID,
|
|
57
|
+
handlerProvider?: HandlerProvider,
|
|
58
|
+
logFn: LogFunction,
|
|
59
|
+
requiredFieldLogger: RequiredFieldLogger,
|
|
60
|
+
treatMissingFieldsAsNull?: boolean,
|
|
61
|
+
}>;
|
|
62
|
+
|
|
63
|
+
class MultiActorEnvironment implements IMultiActorEnvironment {
|
|
64
|
+
+_actorEnvironments: Map<ActorIdentifier, IActorEnvironment>;
|
|
65
|
+
+_createNetworkForActor: (actorIdentifier: ActorIdentifier) => INetwork;
|
|
66
|
+
+_getDataID: GetDataID;
|
|
67
|
+
+_handlerProvider: HandlerProvider;
|
|
68
|
+
+_logFn: LogFunction;
|
|
69
|
+
+_operationExecutions: Map<string, ActiveState>;
|
|
70
|
+
+_requiredFieldLogger: RequiredFieldLogger;
|
|
71
|
+
+_treatMissingFieldsAsNull: boolean;
|
|
72
|
+
|
|
73
|
+
constructor(config: MultiActorEnvironmentConfig) {
|
|
74
|
+
this._actorEnvironments = new Map();
|
|
75
|
+
this._createNetworkForActor = config.createNetworkForActor;
|
|
76
|
+
this._getDataID = config.getDataID ?? defaultGetDataID;
|
|
77
|
+
this._handlerProvider = config.handlerProvider
|
|
78
|
+
? config.handlerProvider
|
|
79
|
+
: RelayDefaultHandlerProvider;
|
|
80
|
+
this._logFn = config.logFn;
|
|
81
|
+
this._operationExecutions = new Map();
|
|
82
|
+
this._requiredFieldLogger = config.requiredFieldLogger;
|
|
83
|
+
this._treatMissingFieldsAsNull = config.treatMissingFieldsAsNull ?? false;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* This method will create an actor specfic environment. It will create a new instance
|
|
88
|
+
* and store it in the internal maps. If will return a memozied version
|
|
89
|
+
* of the environment if we already created one for actor.
|
|
90
|
+
*/
|
|
91
|
+
forActor(actorIdentifier: ActorIdentifier): IEnvironment & IActorEnvironment {
|
|
92
|
+
const environment = this._actorEnvironments.get(actorIdentifier);
|
|
93
|
+
if (environment == null) {
|
|
94
|
+
const newEnvironment = new ActorSpecificEnvironment({
|
|
95
|
+
actorIdentifier,
|
|
96
|
+
multiActorEnvironment: this,
|
|
97
|
+
logFn: this._logFn,
|
|
98
|
+
requiredFieldLogger: this._requiredFieldLogger,
|
|
99
|
+
store: new RelayModernStore(RelayRecordSource.create()),
|
|
100
|
+
network: this._createNetworkForActor(actorIdentifier),
|
|
101
|
+
});
|
|
102
|
+
this._actorEnvironments.set(actorIdentifier, newEnvironment);
|
|
103
|
+
return newEnvironment;
|
|
104
|
+
} else {
|
|
105
|
+
return environment;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
check(
|
|
110
|
+
actorIdentifier: ActorIdentifier,
|
|
111
|
+
operation: OperationDescriptor,
|
|
112
|
+
): OperationAvailability {
|
|
113
|
+
return todo('check');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
subscribe(
|
|
117
|
+
actorIdentifier: ActorIdentifier,
|
|
118
|
+
snapshot: Snapshot,
|
|
119
|
+
callback: (snapshot: Snapshot) => void,
|
|
120
|
+
): Disposable {
|
|
121
|
+
return todo('subscribe');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
retain(
|
|
125
|
+
actorIdentifier: ActorIdentifier,
|
|
126
|
+
operation: OperationDescriptor,
|
|
127
|
+
): Disposable {
|
|
128
|
+
return todo('retain');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
applyUpdate(
|
|
132
|
+
actorIdentifier: ActorIdentifier,
|
|
133
|
+
optimisticUpdate: OptimisticUpdateFunction,
|
|
134
|
+
): Disposable {
|
|
135
|
+
return todo('applyUpdate');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
applyMutation(
|
|
139
|
+
actorIdentifier: ActorIdentifier,
|
|
140
|
+
optimisticConfig: OptimisticResponseConfig,
|
|
141
|
+
): Disposable {
|
|
142
|
+
return todo('applyMutation');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
commitUpdate(actorIdentifier: ActorIdentifier, updater: StoreUpdater): void {
|
|
146
|
+
return todo('commitUpdate');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
commitPayload(
|
|
150
|
+
actorIdentifier: ActorIdentifier,
|
|
151
|
+
operationDescriptor: OperationDescriptor,
|
|
152
|
+
payload: PayloadData,
|
|
153
|
+
): void {
|
|
154
|
+
return todo('commitPayload');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
lookup(
|
|
158
|
+
actorIdentifier: ActorIdentifier,
|
|
159
|
+
selector: SingularReaderSelector,
|
|
160
|
+
): Snapshot {
|
|
161
|
+
return todo('lookup');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
execute(
|
|
165
|
+
actorIdentifier: ActorIdentifier,
|
|
166
|
+
config: {
|
|
167
|
+
operation: OperationDescriptor,
|
|
168
|
+
updater?: ?SelectorStoreUpdater,
|
|
169
|
+
},
|
|
170
|
+
): RelayObservable<GraphQLResponse> {
|
|
171
|
+
const {operation, updater} = config;
|
|
172
|
+
return RelayObservable.create(sink => {
|
|
173
|
+
const actorEnvironemnt = this.forActor(actorIdentifier);
|
|
174
|
+
const source = actorEnvironemnt
|
|
175
|
+
.getNetwork()
|
|
176
|
+
.execute(
|
|
177
|
+
operation.request.node.params,
|
|
178
|
+
operation.request.variables,
|
|
179
|
+
operation.request.cacheConfig || {},
|
|
180
|
+
null,
|
|
181
|
+
);
|
|
182
|
+
const executor = OperationExecutor.execute({
|
|
183
|
+
operation,
|
|
184
|
+
operationExecutions: this._operationExecutions,
|
|
185
|
+
operationLoader: null,
|
|
186
|
+
optimisticConfig: null,
|
|
187
|
+
publishQueue: new RelayPublishQueue(
|
|
188
|
+
actorEnvironemnt.getStore(),
|
|
189
|
+
this._handlerProvider,
|
|
190
|
+
this._getDataID,
|
|
191
|
+
),
|
|
192
|
+
reactFlightPayloadDeserializer: null,
|
|
193
|
+
reactFlightServerErrorHandler: null,
|
|
194
|
+
scheduler: null,
|
|
195
|
+
sink,
|
|
196
|
+
source,
|
|
197
|
+
store: actorEnvironemnt.getStore(),
|
|
198
|
+
updater,
|
|
199
|
+
operationTracker: actorEnvironemnt.getOperationTracker(),
|
|
200
|
+
getDataID: this._getDataID,
|
|
201
|
+
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
202
|
+
shouldProcessClientComponents: false,
|
|
203
|
+
});
|
|
204
|
+
return () => executor.cancel();
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
executeMutation(
|
|
209
|
+
actorIdentifier: ActorIdentifier,
|
|
210
|
+
config: ExecuteMutationConfig,
|
|
211
|
+
): RelayObservable<GraphQLResponse> {
|
|
212
|
+
return todo('executeMutation');
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
executeWithSource(
|
|
216
|
+
actorIdentifier: ActorIdentifier,
|
|
217
|
+
config: {
|
|
218
|
+
operation: OperationDescriptor,
|
|
219
|
+
source: RelayObservable<GraphQLResponse>,
|
|
220
|
+
},
|
|
221
|
+
): RelayObservable<GraphQLResponse> {
|
|
222
|
+
return todo('executeWithSource');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
isRequestActive(
|
|
226
|
+
actorIdentifier: ActorIdentifier,
|
|
227
|
+
requestIdentifier: string,
|
|
228
|
+
): boolean {
|
|
229
|
+
return todo('isRequestActive');
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
module.exports = MultiActorEnvironment;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @emails oncall+relay
|
|
8
|
+
* @flow strict-local
|
|
9
|
+
* @format
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
import type {PayloadData, GraphQLResponse} from '../network/RelayNetworkTypes';
|
|
15
|
+
import type RelayObservable from '../network/RelayObservable';
|
|
16
|
+
import type {
|
|
17
|
+
OperationAvailability,
|
|
18
|
+
OperationDescriptor,
|
|
19
|
+
OptimisticResponseConfig,
|
|
20
|
+
OptimisticUpdateFunction,
|
|
21
|
+
SelectorStoreUpdater,
|
|
22
|
+
SingularReaderSelector,
|
|
23
|
+
Snapshot,
|
|
24
|
+
StoreUpdater,
|
|
25
|
+
IEnvironment,
|
|
26
|
+
ExecuteMutationConfig,
|
|
27
|
+
} from '../store/RelayStoreTypes';
|
|
28
|
+
import type {Disposable} from '../util/RelayRuntimeTypes';
|
|
29
|
+
import type {ActorIdentifier} from './ActorIdentifier';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Interface of actor specific sub-environment
|
|
33
|
+
*/
|
|
34
|
+
export interface IActorEnvironment extends IEnvironment {
|
|
35
|
+
/**
|
|
36
|
+
* Reference to the main MultiActorEnvironment that handles
|
|
37
|
+
* the network execution/and responsible for network integration
|
|
38
|
+
*/
|
|
39
|
+
+multiActorEnvironment: IMultiActorEnvironment;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Identifier of the actor for the current active environment
|
|
43
|
+
*/
|
|
44
|
+
+actorIdentifier: ActorIdentifier;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Interface for the main (or parent) multi-actor environment that contains
|
|
49
|
+
* the map of individual actor-specific sub-environments. These sub-environments
|
|
50
|
+
* implement the Relay IEnvironment interface.
|
|
51
|
+
*/
|
|
52
|
+
export interface IMultiActorEnvironment {
|
|
53
|
+
/**
|
|
54
|
+
* A factory of actor-specific environments.
|
|
55
|
+
*/
|
|
56
|
+
forActor(actorIdentifier: ActorIdentifier): IActorEnvironment;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Determine if the operation can be resolved with data in the store (i.e. no
|
|
60
|
+
* fields are missing).
|
|
61
|
+
*
|
|
62
|
+
* Note that this operation effectively "executes" the selector against the
|
|
63
|
+
* cache and therefore takes time proportional to the size/complexity of the
|
|
64
|
+
* selector.
|
|
65
|
+
*/
|
|
66
|
+
check(
|
|
67
|
+
actorIdentifier: ActorIdentifier,
|
|
68
|
+
operation: OperationDescriptor,
|
|
69
|
+
): OperationAvailability;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Subscribe to changes to the results of a selector. The callback is called
|
|
73
|
+
* when data has been committed to the store that would cause the results of
|
|
74
|
+
* the snapshot's selector to change.
|
|
75
|
+
*/
|
|
76
|
+
subscribe(
|
|
77
|
+
actorIdentifier: ActorIdentifier,
|
|
78
|
+
snapshot: Snapshot,
|
|
79
|
+
callback: (snapshot: Snapshot) => void,
|
|
80
|
+
): Disposable;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Ensure that all the records necessary to fulfill the given selector are
|
|
84
|
+
* retained in-memory. The records will not be eligible for garbage collection
|
|
85
|
+
* until the returned reference is disposed.
|
|
86
|
+
*/
|
|
87
|
+
retain(
|
|
88
|
+
actorIdentifier: ActorIdentifier,
|
|
89
|
+
operation: OperationDescriptor,
|
|
90
|
+
): Disposable;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Apply an optimistic update to the environment. The mutation can be reverted
|
|
94
|
+
* by calling `dispose()` on the returned value.
|
|
95
|
+
*/
|
|
96
|
+
applyUpdate(
|
|
97
|
+
actorIdentifier: ActorIdentifier,
|
|
98
|
+
optimisticUpdate: OptimisticUpdateFunction,
|
|
99
|
+
): Disposable;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Apply an optimistic mutation response and/or updater. The mutation can be
|
|
103
|
+
* reverted by calling `dispose()` on the returned value.
|
|
104
|
+
*/
|
|
105
|
+
applyMutation(
|
|
106
|
+
actorIdentifier: ActorIdentifier,
|
|
107
|
+
optimisticConfig: OptimisticResponseConfig,
|
|
108
|
+
): Disposable;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Commit an updater to the environment. This mutation cannot be reverted and
|
|
112
|
+
* should therefore not be used for optimistic updates. This is mainly
|
|
113
|
+
* intended for updating fields from client schema extensions.
|
|
114
|
+
*/
|
|
115
|
+
commitUpdate(actorIdentifier: ActorIdentifier, updater: StoreUpdater): void;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Commit a payload to the environment using the given operation selector.
|
|
119
|
+
*/
|
|
120
|
+
commitPayload(
|
|
121
|
+
actorIdentifier: ActorIdentifier,
|
|
122
|
+
operationDescriptor: OperationDescriptor,
|
|
123
|
+
payload: PayloadData,
|
|
124
|
+
): void;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Read the results of a selector from in-memory records in the store.
|
|
128
|
+
*/
|
|
129
|
+
lookup(
|
|
130
|
+
actorIdentifier: ActorIdentifier,
|
|
131
|
+
selector: SingularReaderSelector,
|
|
132
|
+
): Snapshot;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Send a query to the server with Observer semantics: one or more
|
|
136
|
+
* responses may be returned (via `next`) over time followed by either
|
|
137
|
+
* the request completing (`completed`) or an error (`error`).
|
|
138
|
+
*
|
|
139
|
+
* Networks/servers that support subscriptions may choose to hold the
|
|
140
|
+
* subscription open indefinitely such that `complete` is not called.
|
|
141
|
+
*
|
|
142
|
+
* Note: Observables are lazy, so calling this method will do nothing until
|
|
143
|
+
* the result is subscribed to: environment.execute({...}).subscribe({...}).
|
|
144
|
+
*/
|
|
145
|
+
execute(
|
|
146
|
+
actorIdentifier: ActorIdentifier,
|
|
147
|
+
config: {
|
|
148
|
+
operation: OperationDescriptor,
|
|
149
|
+
updater?: ?SelectorStoreUpdater,
|
|
150
|
+
},
|
|
151
|
+
): RelayObservable<GraphQLResponse>;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Returns an Observable of GraphQLResponse resulting from executing the
|
|
155
|
+
* provided Mutation operation, the result of which is then normalized and
|
|
156
|
+
* committed to the publish queue along with an optional optimistic response
|
|
157
|
+
* or updater.
|
|
158
|
+
*
|
|
159
|
+
* Note: Observables are lazy, so calling this method will do nothing until
|
|
160
|
+
* the result is subscribed to:
|
|
161
|
+
* environment.executeMutation({...}).subscribe({...}).
|
|
162
|
+
*/
|
|
163
|
+
executeMutation(
|
|
164
|
+
actorIdentifier: ActorIdentifier,
|
|
165
|
+
config: ExecuteMutationConfig,
|
|
166
|
+
): RelayObservable<GraphQLResponse>;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Returns an Observable of GraphQLResponse resulting from executing the
|
|
170
|
+
* provided Query or Subscription operation responses, the result of which is
|
|
171
|
+
* then normalized and committed to the publish queue.
|
|
172
|
+
*
|
|
173
|
+
* Note: Observables are lazy, so calling this method will do nothing until
|
|
174
|
+
* the result is subscribed to:
|
|
175
|
+
* environment.executeWithSource({...}).subscribe({...}).
|
|
176
|
+
*/
|
|
177
|
+
executeWithSource(
|
|
178
|
+
actorIdentifier: ActorIdentifier,
|
|
179
|
+
{
|
|
180
|
+
operation: OperationDescriptor,
|
|
181
|
+
source: RelayObservable<GraphQLResponse>,
|
|
182
|
+
},
|
|
183
|
+
): RelayObservable<GraphQLResponse>;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Returns true if a request is currently "active", meaning it's currently
|
|
187
|
+
* actively receiving payloads or downloading modules, and has not received
|
|
188
|
+
* a final payload yet. Note that a request might still be pending (or "in flight")
|
|
189
|
+
* without actively receiving payload, for example a live query or an
|
|
190
|
+
* active GraphQL subscription
|
|
191
|
+
*/
|
|
192
|
+
isRequestActive(
|
|
193
|
+
actorIdentifier: ActorIdentifier,
|
|
194
|
+
requestIdentifier: string,
|
|
195
|
+
): boolean;
|
|
196
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @emails oncall+relay
|
|
8
|
+
* @flow strict-local
|
|
9
|
+
* @format
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
const MultiActorEnvironment = require('./MultiActorEnvironment');
|
|
15
|
+
|
|
16
|
+
export type {ActorIdentifier} from './ActorIdentifier';
|
|
17
|
+
export type {
|
|
18
|
+
IActorEnvironment,
|
|
19
|
+
IMultiActorEnvironment,
|
|
20
|
+
} from './MultiActorEnvironmentTypes';
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
MultiActorEnvironment,
|
|
24
|
+
};
|
|
@@ -20,9 +20,10 @@ import type RelayObservable, {ObservableFromValue} from './RelayObservable';
|
|
|
20
20
|
* An interface for fetching the data for one or more (possibly interdependent)
|
|
21
21
|
* queries.
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
24
|
-
execute: ExecuteFunction
|
|
25
|
-
|
|
23
|
+
export interface INetwork {
|
|
24
|
+
+execute: ExecuteFunction;
|
|
25
|
+
}
|
|
26
|
+
|
|
26
27
|
export type LogRequestInfoFunction = mixed => void;
|
|
27
28
|
|
|
28
29
|
export type PayloadData = interface {[key: string]: mixed};
|
|
@@ -42,7 +43,7 @@ export type PayloadExtensions = {[key: string]: mixed, ...};
|
|
|
42
43
|
|
|
43
44
|
/**
|
|
44
45
|
* The shape of a GraphQL response as dictated by the
|
|
45
|
-
* [spec](https://graphql.
|
|
46
|
+
* [spec](https://spec.graphql.org/June2018/#sec-Response-Format).
|
|
46
47
|
*/
|
|
47
48
|
export type GraphQLResponseWithData = {|
|
|
48
49
|
+data: PayloadData,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "relay-runtime",
|
|
3
3
|
"description": "A core runtime for building GraphQL-driven applications.",
|
|
4
|
-
"version": "11.0.
|
|
4
|
+
"version": "11.0.2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
7
7
|
"relay"
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"repository": "facebook/relay",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@babel/runtime": "^7.0.0",
|
|
15
|
-
"fbjs": "^3.0.0"
|
|
15
|
+
"fbjs": "^3.0.0",
|
|
16
|
+
"invariant": "^2.2.4"
|
|
16
17
|
},
|
|
17
18
|
"directories": {
|
|
18
19
|
"": "./"
|