relay-runtime 0.0.0-main-1decb243 → 0.0.0-main-c52ed92a
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/experimental.js +1 -1
- package/index.js +1 -1
- package/lib/experimental.js +3 -3
- package/lib/handlers/RelayDefaultHandlerProvider.js +12 -12
- package/lib/handlers/connection/ConnectionHandler.js +17 -17
- package/lib/handlers/connection/ConnectionInterface.js +10 -10
- package/lib/handlers/connection/MutationHandlers.js +16 -16
- package/lib/index.js +61 -61
- package/lib/multi-actor-environment/ActorIdentifier.js +5 -5
- package/lib/multi-actor-environment/ActorSpecificEnvironment.js +8 -8
- package/lib/multi-actor-environment/ActorUtils.js +4 -4
- package/lib/multi-actor-environment/MultiActorEnvironment.js +12 -12
- package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +1 -1
- package/lib/multi-actor-environment/index.js +3 -3
- package/lib/mutations/RelayDeclarativeMutationConfig.js +26 -26
- package/lib/mutations/RelayRecordProxy.js +9 -9
- package/lib/mutations/RelayRecordSourceMutator.js +7 -7
- package/lib/mutations/RelayRecordSourceProxy.js +12 -12
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +9 -9
- package/lib/mutations/applyOptimisticMutation.js +9 -9
- package/lib/mutations/commitLocalUpdate.js +1 -1
- package/lib/mutations/commitMutation.js +15 -15
- package/lib/mutations/createUpdatableProxy.js +13 -13
- package/lib/mutations/readUpdatableFragment.js +6 -6
- package/lib/mutations/readUpdatableQuery.js +3 -3
- package/lib/mutations/validateMutation.js +9 -7
- package/lib/network/ConvertToExecuteFunction.js +2 -2
- package/lib/network/RelayNetwork.js +8 -8
- package/lib/network/RelayNetworkTypes.js +1 -1
- package/lib/network/RelayObservable.js +23 -22
- package/lib/network/RelayQueryResponseCache.js +5 -5
- package/lib/network/wrapNetworkWithLogObserver.js +8 -8
- package/lib/query/GraphQLTag.js +16 -16
- package/lib/query/PreloadableQueryRegistry.js +1 -1
- package/lib/query/fetchQuery.js +13 -13
- package/lib/query/fetchQueryInternal.js +8 -8
- package/lib/query/fetchQuery_DEPRECATED.js +5 -5
- package/lib/store/ClientID.js +7 -7
- package/lib/store/DataChecker.js +29 -25
- package/lib/store/OperationExecutor.js +87 -87
- package/lib/store/RelayConcreteVariables.js +6 -6
- package/lib/store/RelayExperimentalGraphResponseHandler.js +12 -12
- package/lib/store/RelayExperimentalGraphResponseTransform.js +16 -16
- package/lib/store/RelayModernEnvironment.js +21 -21
- package/lib/store/RelayModernFragmentSpecResolver.js +16 -16
- package/lib/store/RelayModernOperationDescriptor.js +6 -6
- package/lib/store/RelayModernRecord.js +23 -23
- package/lib/store/RelayModernSelector.js +23 -23
- package/lib/store/RelayModernStore.js +35 -35
- package/lib/store/RelayOperationTracker.js +3 -3
- package/lib/store/RelayOptimisticRecordSource.js +8 -8
- package/lib/store/RelayPublishQueue.js +22 -22
- package/lib/store/RelayReader.js +48 -50
- package/lib/store/RelayRecordSource.js +3 -3
- package/lib/store/RelayRecordState.js +4 -4
- package/lib/store/RelayReferenceMarker.js +18 -14
- package/lib/store/RelayResponseNormalizer.js +40 -36
- package/lib/store/RelayStoreSubscriptions.js +8 -8
- package/lib/store/RelayStoreTypes.js +1 -1
- package/lib/store/RelayStoreUtils.js +40 -35
- package/lib/store/ResolverCache.js +16 -16
- package/lib/store/ResolverFragments.js +6 -6
- package/lib/store/StoreInspector.js +16 -16
- package/lib/store/TypeID.js +3 -3
- package/lib/store/ViewerPattern.js +5 -5
- package/lib/store/cloneRelayHandleSourceField.js +6 -6
- package/lib/store/cloneRelayScalarHandleSourceField.js +6 -6
- package/lib/store/createFragmentSpecResolver.js +3 -3
- package/lib/store/createRelayContext.js +4 -4
- package/lib/store/defaultGetDataID.js +2 -2
- package/lib/store/defaultRequiredFieldLogger.js +3 -3
- package/lib/store/experimental-live-resolvers/LiveResolverCache.js +33 -33
- package/lib/store/experimental-live-resolvers/LiveResolverStore.js +36 -36
- package/lib/store/experimental-live-resolvers/LiveResolverSuspenseSentinel.js +1 -1
- package/lib/store/experimental-live-resolvers/getOutputTypeRecordIDs.js +5 -5
- package/lib/store/experimental-live-resolvers/isLiveStateValue.js +2 -2
- package/lib/store/experimental-live-resolvers/resolverDataInjector.js +6 -6
- package/lib/store/experimental-live-resolvers/weakObjectWrapper.js +6 -6
- package/lib/store/hasOverlappingIDs.js +1 -1
- package/lib/store/hasSignificantOverlappingIDs.js +3 -3
- package/lib/store/isRelayModernEnvironment.js +2 -2
- package/lib/store/normalizeResponse.js +1 -1
- package/lib/store/readInlineData.js +6 -6
- package/lib/subscription/requestSubscription.js +9 -9
- 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 +36 -36
- package/lib/util/RelayDefaultHandleKey.js +2 -2
- package/lib/util/RelayError.js +3 -3
- package/lib/util/RelayFeatureFlags.js +1 -1
- package/lib/util/RelayProfiler.js +1 -1
- package/lib/util/RelayReplaySubject.js +10 -10
- package/lib/util/RelayRuntimeTypes.js +1 -1
- package/lib/util/StringInterner.js +3 -3
- package/lib/util/createPayloadFor3DField.js +2 -2
- package/lib/util/deepFreeze.js +3 -3
- package/lib/util/generateID.js +1 -1
- package/lib/util/getFragmentIdentifier.js +12 -12
- package/lib/util/getOperation.js +2 -2
- package/lib/util/getPaginationMetadata.js +6 -6
- package/lib/util/getPaginationVariables.js +9 -9
- package/lib/util/getPendingOperationsForFragment.js +5 -5
- package/lib/util/getRefetchMetadata.js +7 -7
- package/lib/util/getRelayHandleKey.js +4 -4
- package/lib/util/getRequestIdentifier.js +4 -4
- package/lib/util/getValueAtPath.js +5 -5
- package/lib/util/handlePotentialSnapshotErrors.js +6 -6
- package/lib/util/isEmptyObject.js +1 -1
- package/lib/util/isPromise.js +2 -2
- package/lib/util/isScalarAndEqual.js +2 -2
- package/lib/util/recycleNodesInto.js +6 -20
- package/lib/util/registerEnvironmentWithDevTools.js +2 -2
- package/lib/util/resolveImmediate.js +1 -1
- package/lib/util/stableCopy.js +2 -2
- package/lib/util/withDuration.js +2 -2
- package/lib/util/withProvidedVariables.js +3 -3
- package/mutations/validateMutation.js.flow +2 -0
- package/network/RelayObservable.js.flow +3 -2
- package/package.json +1 -1
- package/relay-runtime-experimental.js +2 -2
- package/relay-runtime-experimental.min.js +2 -2
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/DataChecker.js.flow +9 -1
- package/store/RelayModernSelector.js.flow +6 -3
- package/store/RelayReader.js.flow +7 -7
- package/store/RelayReferenceMarker.js.flow +6 -1
- package/store/RelayResponseNormalizer.js.flow +6 -1
- package/store/RelayStoreTypes.js.flow +7 -1
- package/store/RelayStoreUtils.js.flow +22 -7
- package/store/experimental-live-resolvers/resolverDataInjector.js.flow +1 -0
- package/store/experimental-live-resolvers/weakObjectWrapper.js.flow +1 -0
- package/util/NormalizationNode.js.flow +15 -2
- package/util/ReaderNode.js.flow +1 -1
- package/util/createPayloadFor3DField.js.flow +1 -0
- package/util/recycleNodesInto.js.flow +8 -30
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import type {ActorIdentifier} from '../multi-actor-environment/ActorIdentifier';
|
|
15
15
|
import type {
|
|
16
16
|
NormalizationLinkedField,
|
|
17
|
+
NormalizationLiveResolverField,
|
|
17
18
|
NormalizationModuleImport,
|
|
18
19
|
NormalizationNode,
|
|
19
20
|
NormalizationResolverField,
|
|
@@ -62,6 +63,7 @@ const {
|
|
|
62
63
|
LINKED_HANDLE,
|
|
63
64
|
MODULE_IMPORT,
|
|
64
65
|
RELAY_RESOLVER,
|
|
66
|
+
RELAY_LIVE_RESOLVER,
|
|
65
67
|
SCALAR_FIELD,
|
|
66
68
|
SCALAR_HANDLE,
|
|
67
69
|
STREAM,
|
|
@@ -455,6 +457,9 @@ class DataChecker {
|
|
|
455
457
|
case RELAY_RESOLVER:
|
|
456
458
|
this._checkResolver(selection, dataID);
|
|
457
459
|
break;
|
|
460
|
+
case RELAY_LIVE_RESOLVER:
|
|
461
|
+
this._checkResolver(selection, dataID);
|
|
462
|
+
break;
|
|
458
463
|
case CLIENT_EDGE_TO_CLIENT_OBJECT:
|
|
459
464
|
this._checkResolver(selection.backingField, dataID);
|
|
460
465
|
break;
|
|
@@ -468,7 +473,10 @@ class DataChecker {
|
|
|
468
473
|
}
|
|
469
474
|
});
|
|
470
475
|
}
|
|
471
|
-
_checkResolver(
|
|
476
|
+
_checkResolver(
|
|
477
|
+
resolver: NormalizationResolverField | NormalizationLiveResolverField,
|
|
478
|
+
dataID: DataID,
|
|
479
|
+
) {
|
|
472
480
|
if (resolver.fragment) {
|
|
473
481
|
this._traverseSelections([resolver.fragment], dataID);
|
|
474
482
|
}
|
|
@@ -27,9 +27,9 @@ const {getFragmentVariables} = require('./RelayConcreteVariables');
|
|
|
27
27
|
const {
|
|
28
28
|
CLIENT_EDGE_TRAVERSAL_PATH,
|
|
29
29
|
FRAGMENT_OWNER_KEY,
|
|
30
|
+
FRAGMENT_POINTER_IS_WITHIN_UNMATCHED_TYPE_REFINEMENT,
|
|
30
31
|
FRAGMENTS_KEY,
|
|
31
32
|
ID_KEY,
|
|
32
|
-
IS_WITHIN_UNMATCHED_TYPE_REFINEMENT,
|
|
33
33
|
} = require('./RelayStoreUtils');
|
|
34
34
|
const areEqual = require('areEqual');
|
|
35
35
|
const invariant = require('invariant');
|
|
@@ -78,8 +78,6 @@ function getSingularSelector(
|
|
|
78
78
|
const dataID = item[ID_KEY];
|
|
79
79
|
const fragments = item[FRAGMENTS_KEY];
|
|
80
80
|
const mixedOwner = item[FRAGMENT_OWNER_KEY];
|
|
81
|
-
const isWithinUnmatchedTypeRefinement =
|
|
82
|
-
item[IS_WITHIN_UNMATCHED_TYPE_REFINEMENT] === true;
|
|
83
81
|
const mixedClientEdgeTraversalPath = item[CLIENT_EDGE_TRAVERSAL_PATH];
|
|
84
82
|
if (
|
|
85
83
|
typeof dataID === 'string' &&
|
|
@@ -103,6 +101,11 @@ function getSingularSelector(
|
|
|
103
101
|
argumentVariables,
|
|
104
102
|
);
|
|
105
103
|
|
|
104
|
+
const isWithinUnmatchedTypeRefinement =
|
|
105
|
+
argumentVariables[
|
|
106
|
+
FRAGMENT_POINTER_IS_WITHIN_UNMATCHED_TYPE_REFINEMENT
|
|
107
|
+
] === true;
|
|
108
|
+
|
|
106
109
|
return createReaderSelector(
|
|
107
110
|
fragment,
|
|
108
111
|
dataID,
|
|
@@ -79,7 +79,6 @@ const {
|
|
|
79
79
|
FRAGMENT_PROP_NAME_KEY,
|
|
80
80
|
FRAGMENTS_KEY,
|
|
81
81
|
ID_KEY,
|
|
82
|
-
IS_WITHIN_UNMATCHED_TYPE_REFINEMENT,
|
|
83
82
|
MODULE_COMPONENT_KEY,
|
|
84
83
|
ROOT_ID,
|
|
85
84
|
getArgumentValues,
|
|
@@ -1065,7 +1064,7 @@ class RelayReader {
|
|
|
1065
1064
|
let fragmentPointers = data[FRAGMENTS_KEY];
|
|
1066
1065
|
if (fragmentPointers == null) {
|
|
1067
1066
|
fragmentPointers = data[FRAGMENTS_KEY] = ({}: {
|
|
1068
|
-
[string]: Arguments
|
|
1067
|
+
[string]: Arguments,
|
|
1069
1068
|
});
|
|
1070
1069
|
}
|
|
1071
1070
|
invariant(
|
|
@@ -1073,16 +1072,17 @@ class RelayReader {
|
|
|
1073
1072
|
'RelayReader: Expected fragment spread data to be an object, got `%s`.',
|
|
1074
1073
|
fragmentPointers,
|
|
1075
1074
|
);
|
|
1075
|
+
|
|
1076
1076
|
if (data[ID_KEY] == null) {
|
|
1077
1077
|
data[ID_KEY] = RelayModernRecord.getDataID(record);
|
|
1078
1078
|
}
|
|
1079
1079
|
// $FlowFixMe[cannot-write] - writing into read-only field
|
|
1080
|
-
fragmentPointers[fragmentSpread.name] =
|
|
1081
|
-
|
|
1082
|
-
|
|
1080
|
+
fragmentPointers[fragmentSpread.name] = getArgumentValues(
|
|
1081
|
+
fragmentSpread.args,
|
|
1082
|
+
this._variables,
|
|
1083
|
+
this._isWithinUnmatchedTypeRefinement,
|
|
1084
|
+
);
|
|
1083
1085
|
data[FRAGMENT_OWNER_KEY] = this._owner;
|
|
1084
|
-
data[IS_WITHIN_UNMATCHED_TYPE_REFINEMENT] =
|
|
1085
|
-
this._isWithinUnmatchedTypeRefinement;
|
|
1086
1086
|
|
|
1087
1087
|
if (RelayFeatureFlags.ENABLE_CLIENT_EDGES) {
|
|
1088
1088
|
if (
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import type {
|
|
15
15
|
NormalizationClientEdgeToClientObject,
|
|
16
16
|
NormalizationLinkedField,
|
|
17
|
+
NormalizationLiveResolverField,
|
|
17
18
|
NormalizationModuleImport,
|
|
18
19
|
NormalizationNode,
|
|
19
20
|
NormalizationResolverField,
|
|
@@ -54,6 +55,7 @@ const {
|
|
|
54
55
|
STREAM,
|
|
55
56
|
TYPE_DISCRIMINATOR,
|
|
56
57
|
RELAY_RESOLVER,
|
|
58
|
+
RELAY_LIVE_RESOLVER,
|
|
57
59
|
CLIENT_EDGE_TO_CLIENT_OBJECT,
|
|
58
60
|
} = RelayConcreteNode;
|
|
59
61
|
const {getStorageKey, getModuleOperationKey} = RelayStoreUtils;
|
|
@@ -236,6 +238,9 @@ class RelayReferenceMarker {
|
|
|
236
238
|
case RELAY_RESOLVER:
|
|
237
239
|
this._traverseResolverField(selection, record);
|
|
238
240
|
break;
|
|
241
|
+
case RELAY_LIVE_RESOLVER:
|
|
242
|
+
this._traverseResolverField(selection, record);
|
|
243
|
+
break;
|
|
239
244
|
case CLIENT_EDGE_TO_CLIENT_OBJECT:
|
|
240
245
|
this._traverseClientEdgeToClientObject(selection, record);
|
|
241
246
|
break;
|
|
@@ -303,7 +308,7 @@ class RelayReferenceMarker {
|
|
|
303
308
|
}
|
|
304
309
|
|
|
305
310
|
_traverseResolverField(
|
|
306
|
-
field: NormalizationResolverField,
|
|
311
|
+
field: NormalizationResolverField | NormalizationLiveResolverField,
|
|
307
312
|
record: Record,
|
|
308
313
|
): ?DataID {
|
|
309
314
|
const storageKey = getStorageKey(field, this._variables);
|
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
NormalizationActorChange,
|
|
18
18
|
NormalizationDefer,
|
|
19
19
|
NormalizationLinkedField,
|
|
20
|
+
NormalizationLiveResolverField,
|
|
20
21
|
NormalizationModuleImport,
|
|
21
22
|
NormalizationNode,
|
|
22
23
|
NormalizationResolverField,
|
|
@@ -50,6 +51,7 @@ const {
|
|
|
50
51
|
LINKED_FIELD,
|
|
51
52
|
LINKED_HANDLE,
|
|
52
53
|
MODULE_IMPORT,
|
|
54
|
+
RELAY_LIVE_RESOLVER,
|
|
53
55
|
RELAY_RESOLVER,
|
|
54
56
|
SCALAR_FIELD,
|
|
55
57
|
SCALAR_HANDLE,
|
|
@@ -327,6 +329,9 @@ class RelayResponseNormalizer {
|
|
|
327
329
|
case RELAY_RESOLVER:
|
|
328
330
|
this._normalizeResolver(selection, record, data);
|
|
329
331
|
break;
|
|
332
|
+
case RELAY_LIVE_RESOLVER:
|
|
333
|
+
this._normalizeResolver(selection, record, data);
|
|
334
|
+
break;
|
|
330
335
|
case CLIENT_EDGE_TO_CLIENT_OBJECT:
|
|
331
336
|
this._normalizeResolver(selection.backingField, record, data);
|
|
332
337
|
break;
|
|
@@ -342,7 +347,7 @@ class RelayResponseNormalizer {
|
|
|
342
347
|
}
|
|
343
348
|
|
|
344
349
|
_normalizeResolver(
|
|
345
|
-
resolver: NormalizationResolverField,
|
|
350
|
+
resolver: NormalizationResolverField | NormalizationLiveResolverField,
|
|
346
351
|
record: Record,
|
|
347
352
|
data: PayloadData,
|
|
348
353
|
) {
|
|
@@ -714,6 +714,11 @@ export type LiveResolverBatchEndLogEvent = {
|
|
|
714
714
|
+name: 'liveresolver.batch.end',
|
|
715
715
|
};
|
|
716
716
|
|
|
717
|
+
export type UseFragmentSubscriptionMissedUpdates = {
|
|
718
|
+
+name: 'useFragment.subscription.missedUpdates',
|
|
719
|
+
+hasDataChanges: boolean,
|
|
720
|
+
};
|
|
721
|
+
|
|
717
722
|
export type LogEvent =
|
|
718
723
|
| SuspenseFragmentLogEvent
|
|
719
724
|
| SuspenseQueryLogEvent
|
|
@@ -741,7 +746,8 @@ export type LogEvent =
|
|
|
741
746
|
| StoreNotifySubscriptionLogEvent
|
|
742
747
|
| EntrypointRootConsumeLogEvent
|
|
743
748
|
| LiveResolverBatchStartLogEvent
|
|
744
|
-
| LiveResolverBatchEndLogEvent
|
|
749
|
+
| LiveResolverBatchEndLogEvent
|
|
750
|
+
| UseFragmentSubscriptionMissedUpdates;
|
|
745
751
|
|
|
746
752
|
export type LogFunction = LogEvent => void;
|
|
747
753
|
export type LogRequestInfoFunction = mixed => void;
|
|
@@ -31,7 +31,10 @@ const RelayConcreteNode = require('../util/RelayConcreteNode');
|
|
|
31
31
|
const stableCopy = require('../util/stableCopy');
|
|
32
32
|
const invariant = require('invariant');
|
|
33
33
|
|
|
34
|
-
export type Arguments = {
|
|
34
|
+
export type Arguments = {
|
|
35
|
+
+FRAGMENT_POINTER_IS_WITHIN_UNMATCHED_TYPE_REFINEMENT?: boolean,
|
|
36
|
+
+[string]: mixed,
|
|
37
|
+
};
|
|
35
38
|
|
|
36
39
|
const {VARIABLE, LITERAL, OBJECT_VALUE, LIST_VALUE} = RelayConcreteNode;
|
|
37
40
|
|
|
@@ -68,13 +71,24 @@ function getArgumentValue(
|
|
|
68
71
|
* names. Guaranteed to return a result with stable ordered nested values.
|
|
69
72
|
*/
|
|
70
73
|
function getArgumentValues(
|
|
71
|
-
args
|
|
74
|
+
args?: ?$ReadOnlyArray<NormalizationArgument | ReaderArgument>,
|
|
72
75
|
variables: Variables,
|
|
76
|
+
isWithinUnmatchedTypeRefinement?: boolean,
|
|
73
77
|
): Arguments {
|
|
74
|
-
const values: {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
+
const values: {
|
|
79
|
+
FRAGMENT_POINTER_IS_WITHIN_UNMATCHED_TYPE_REFINEMENT?: boolean,
|
|
80
|
+
[string]: mixed,
|
|
81
|
+
} = {};
|
|
82
|
+
if (isWithinUnmatchedTypeRefinement == true) {
|
|
83
|
+
values[
|
|
84
|
+
RelayStoreUtils.FRAGMENT_POINTER_IS_WITHIN_UNMATCHED_TYPE_REFINEMENT
|
|
85
|
+
] = true;
|
|
86
|
+
}
|
|
87
|
+
if (args) {
|
|
88
|
+
args.forEach(arg => {
|
|
89
|
+
values[arg.name] = getArgumentValue(arg, variables);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
78
92
|
return values;
|
|
79
93
|
}
|
|
80
94
|
|
|
@@ -239,6 +253,8 @@ const RelayStoreUtils = {
|
|
|
239
253
|
CLIENT_EDGE_TRAVERSAL_PATH: '__clientEdgeTraversalPath',
|
|
240
254
|
FRAGMENTS_KEY: '__fragments',
|
|
241
255
|
FRAGMENT_OWNER_KEY: '__fragmentOwner',
|
|
256
|
+
FRAGMENT_POINTER_IS_WITHIN_UNMATCHED_TYPE_REFINEMENT:
|
|
257
|
+
'$isWithinUnmatchedTypeRefinement',
|
|
242
258
|
FRAGMENT_PROP_NAME_KEY: '__fragmentPropName',
|
|
243
259
|
MODULE_COMPONENT_KEY: '__module_component', // alias returned by Reader
|
|
244
260
|
ID_KEY: '__id',
|
|
@@ -248,7 +264,6 @@ const RelayStoreUtils = {
|
|
|
248
264
|
ROOT_TYPE: '__Root',
|
|
249
265
|
TYPENAME_KEY: '__typename',
|
|
250
266
|
INVALIDATED_AT_KEY: '__invalidated_at',
|
|
251
|
-
IS_WITHIN_UNMATCHED_TYPE_REFINEMENT: '__isWithinUnmatchedTypeRefinement',
|
|
252
267
|
RELAY_RESOLVER_VALUE_KEY: '__resolverValue',
|
|
253
268
|
RELAY_RESOLVER_INVALIDATION_KEY: '__resolverValueMayBeInvalid',
|
|
254
269
|
RELAY_RESOLVER_SNAPSHOT_KEY: '__resolverSnapshot',
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
import type {ResolverModule} from './ReaderNode';
|
|
14
15
|
import type {ConcreteRequest} from './RelayConcreteNode';
|
|
15
16
|
import type {JSResourceReference} from 'JSResourceReference';
|
|
16
17
|
|
|
@@ -78,6 +79,7 @@ export type NormalizationClientExtension = {
|
|
|
78
79
|
|
|
79
80
|
export type NormalizationField =
|
|
80
81
|
| NormalizationResolverField
|
|
82
|
+
| NormalizationLiveResolverField
|
|
81
83
|
| NormalizationScalarField
|
|
82
84
|
| NormalizationLinkedField;
|
|
83
85
|
|
|
@@ -167,15 +169,26 @@ export type NormalizationResolverField = {
|
|
|
167
169
|
+kind: 'RelayResolver',
|
|
168
170
|
+name: string,
|
|
169
171
|
+args: ?$ReadOnlyArray<NormalizationArgument>,
|
|
170
|
-
+fragment
|
|
172
|
+
+fragment?: ?NormalizationInlineFragment,
|
|
171
173
|
+storageKey: ?string,
|
|
172
174
|
+isOutputType: boolean,
|
|
175
|
+
+resolverModule?: ResolverModule,
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export type NormalizationLiveResolverField = {
|
|
179
|
+
+kind: 'RelayLiveResolver',
|
|
180
|
+
+name: string,
|
|
181
|
+
+args: ?$ReadOnlyArray<NormalizationArgument>,
|
|
182
|
+
+fragment?: ?NormalizationInlineFragment,
|
|
183
|
+
+storageKey: ?string,
|
|
184
|
+
+isOutputType: boolean,
|
|
185
|
+
+resolverModule?: ResolverModule,
|
|
173
186
|
};
|
|
174
187
|
|
|
175
188
|
export type NormalizationClientEdgeToClientObject = {
|
|
176
189
|
+kind: 'ClientEdgeToClientObject',
|
|
177
190
|
+linkedField: NormalizationLinkedField,
|
|
178
|
-
+backingField: NormalizationResolverField,
|
|
191
|
+
+backingField: NormalizationResolverField | NormalizationLiveResolverField,
|
|
179
192
|
};
|
|
180
193
|
|
|
181
194
|
export type NormalizationClientComponent = {
|
package/util/ReaderNode.js.flow
CHANGED
|
@@ -241,7 +241,7 @@ export type ReaderRequiredField = {
|
|
|
241
241
|
|
|
242
242
|
type ResolverFunction = (...args: Array<any>) => mixed; // flowlint-line unclear-type:off
|
|
243
243
|
// With ES6 imports, a resolver function might be exported under the `default` key.
|
|
244
|
-
type ResolverModule = ResolverFunction | {default: ResolverFunction};
|
|
244
|
+
export type ResolverModule = ResolverFunction | {default: ResolverFunction};
|
|
245
245
|
|
|
246
246
|
export type ResolverNormalizationInfo = {
|
|
247
247
|
+concreteType: string | null,
|
|
@@ -25,6 +25,7 @@ export opaque type Local3DPayload<
|
|
|
25
25
|
+Response: {...},
|
|
26
26
|
> = Response;
|
|
27
27
|
|
|
28
|
+
// $FlowFixMe[unsupported-variance-annotation]
|
|
28
29
|
function createPayloadFor3DField<+DocumentName: string, +Response: {...}>(
|
|
29
30
|
name: DocumentName,
|
|
30
31
|
operation: JSResourceReference<NormalizationSplitOperation>,
|
|
@@ -11,9 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
const hasWeakSetDefined = typeof WeakSet !== 'undefined';
|
|
15
|
-
const hasWeakMapDefined = typeof WeakMap !== 'undefined';
|
|
16
|
-
|
|
17
14
|
/**
|
|
18
15
|
* Recycles subtrees from `prevData` by replacing equal subtrees in `nextData`.
|
|
19
16
|
*/
|
|
@@ -21,17 +18,11 @@ function recycleNodesInto<T>(prevData: T, nextData: T): T {
|
|
|
21
18
|
if (
|
|
22
19
|
prevData === nextData ||
|
|
23
20
|
typeof prevData !== 'object' ||
|
|
24
|
-
prevData instanceof Set ||
|
|
25
|
-
prevData instanceof Map ||
|
|
26
|
-
(hasWeakSetDefined && prevData instanceof WeakSet) ||
|
|
27
|
-
(hasWeakMapDefined && prevData instanceof WeakMap) ||
|
|
28
21
|
!prevData ||
|
|
22
|
+
(prevData.constructor !== Object && !Array.isArray(prevData)) ||
|
|
29
23
|
typeof nextData !== 'object' ||
|
|
30
|
-
nextData
|
|
31
|
-
nextData
|
|
32
|
-
(hasWeakSetDefined && nextData instanceof WeakSet) ||
|
|
33
|
-
(hasWeakMapDefined && nextData instanceof WeakMap) ||
|
|
34
|
-
!nextData
|
|
24
|
+
!nextData ||
|
|
25
|
+
(nextData.constructor !== Object && !Array.isArray(nextData))
|
|
35
26
|
) {
|
|
36
27
|
return nextData;
|
|
37
28
|
}
|
|
@@ -45,14 +36,8 @@ function recycleNodesInto<T>(prevData: T, nextData: T): T {
|
|
|
45
36
|
nextArray.reduce((wasEqual, nextItem, ii) => {
|
|
46
37
|
const prevValue = prevArray[ii];
|
|
47
38
|
const nextValue = recycleNodesInto(prevValue, nextItem);
|
|
48
|
-
if (nextValue !== nextArray[ii]) {
|
|
49
|
-
|
|
50
|
-
if (!Object.isFrozen(nextArray)) {
|
|
51
|
-
nextArray[ii] = nextValue;
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
nextArray[ii] = nextValue;
|
|
55
|
-
}
|
|
39
|
+
if (nextValue !== nextArray[ii] && !Object.isFrozen(nextArray)) {
|
|
40
|
+
nextArray[ii] = nextValue;
|
|
56
41
|
}
|
|
57
42
|
return wasEqual && nextValue === prevArray[ii];
|
|
58
43
|
}, true) && prevArray.length === nextArray.length;
|
|
@@ -66,16 +51,9 @@ function recycleNodesInto<T>(prevData: T, nextData: T): T {
|
|
|
66
51
|
nextKeys.reduce((wasEqual, key) => {
|
|
67
52
|
const prevValue = prevObject[key];
|
|
68
53
|
const nextValue = recycleNodesInto(prevValue, nextObject[key]);
|
|
69
|
-
if (nextValue !== nextObject[key]) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// $FlowFixMe[cannot-write]
|
|
73
|
-
nextObject[key] = nextValue;
|
|
74
|
-
}
|
|
75
|
-
} else {
|
|
76
|
-
// $FlowFixMe[cannot-write]
|
|
77
|
-
nextObject[key] = nextValue;
|
|
78
|
-
}
|
|
54
|
+
if (nextValue !== nextObject[key] && !Object.isFrozen(nextObject)) {
|
|
55
|
+
// $FlowFixMe[cannot-write]
|
|
56
|
+
nextObject[key] = nextValue;
|
|
79
57
|
}
|
|
80
58
|
return wasEqual && nextValue === prevObject[key];
|
|
81
59
|
}, true) && prevKeys.length === nextKeys.length;
|