relay-runtime 0.0.0-main-6b2ec499 → 0.0.0-main-0796537a
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/mutations/createUpdatableProxy.js +0 -1
- package/lib/network/ConvertToExecuteFunction.js +0 -1
- package/lib/store/RelayConcreteVariables.js +0 -1
- package/lib/store/RelayModernRecord.js +45 -9
- package/lib/store/RelayPublishQueue.js +1 -3
- package/lib/store/RelayReferenceMarker.js +49 -19
- package/lib/store/RelayResponseNormalizer.js +1 -6
- package/lib/store/defaultGetDataID.js +0 -2
- package/lib/util/deepFreeze.js +0 -1
- package/lib/util/getPendingOperationsForFragment.js +10 -0
- package/mutations/createUpdatableProxy.js.flow +0 -1
- package/network/ConvertToExecuteFunction.js.flow +0 -1
- package/package.json +1 -1
- package/relay-runtime-experimental.js +1 -1
- package/relay-runtime-experimental.min.js +1 -1
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/RelayConcreteVariables.js.flow +0 -1
- package/store/RelayModernRecord.js.flow +57 -1
- package/store/RelayPublishQueue.js.flow +0 -1
- package/store/RelayReferenceMarker.js.flow +36 -8
- package/store/RelayResponseNormalizer.js.flow +1 -5
- package/store/RelayStoreTypes.js.flow +9 -0
- package/store/defaultGetDataID.js.flow +0 -2
- package/util/deepFreeze.js.flow +0 -1
- package/util/getPendingOperationsForFragment.js.flow +10 -0
|
@@ -124,7 +124,6 @@ function getLocalVariables(
|
|
|
124
124
|
const nextVariables = {...currentVariables};
|
|
125
125
|
const nextArgs = args ? getArgumentValues(args, currentVariables) : {};
|
|
126
126
|
argumentDefinitions.forEach(def => {
|
|
127
|
-
// $FlowFixMe[cannot-write]
|
|
128
127
|
const value = nextArgs[def.name] ?? def.defaultValue;
|
|
129
128
|
nextVariables[def.name] = value;
|
|
130
129
|
});
|
|
@@ -16,13 +16,17 @@ import type {DataID} from '../util/RelayRuntimeTypes';
|
|
|
16
16
|
import type {Record} from './RelayStoreTypes';
|
|
17
17
|
|
|
18
18
|
const deepFreeze = require('../util/deepFreeze');
|
|
19
|
-
const {isClientID} = require('./ClientID');
|
|
19
|
+
const {generateClientObjectClientID, isClientID} = require('./ClientID');
|
|
20
|
+
const {
|
|
21
|
+
isSuspenseSentinel,
|
|
22
|
+
} = require('./experimental-live-resolvers/LiveResolverSuspenseSentinel');
|
|
20
23
|
const {
|
|
21
24
|
ACTOR_IDENTIFIER_KEY,
|
|
22
25
|
ID_KEY,
|
|
23
26
|
INVALIDATED_AT_KEY,
|
|
24
27
|
REF_KEY,
|
|
25
28
|
REFS_KEY,
|
|
29
|
+
RELAY_RESOLVER_VALUE_KEY,
|
|
26
30
|
ROOT_ID,
|
|
27
31
|
TYPENAME_KEY,
|
|
28
32
|
} = require('./RelayStoreUtils');
|
|
@@ -441,6 +445,56 @@ function getActorLinkedRecordID(
|
|
|
441
445
|
return [(link[ACTOR_IDENTIFIER_KEY]: any), (link[REF_KEY]: any)];
|
|
442
446
|
}
|
|
443
447
|
|
|
448
|
+
function getResolverLinkedRecordID(record: Record, typeName: string): ?DataID {
|
|
449
|
+
let id = getValue(record, RELAY_RESOLVER_VALUE_KEY);
|
|
450
|
+
if (id == null || isSuspenseSentinel(id)) {
|
|
451
|
+
return null;
|
|
452
|
+
}
|
|
453
|
+
// TODD: Deprecate client edges that return just id.
|
|
454
|
+
if (typeof id === 'object') {
|
|
455
|
+
id = id.id;
|
|
456
|
+
}
|
|
457
|
+
invariant(
|
|
458
|
+
typeof id === 'string',
|
|
459
|
+
'RelayModernRecord.getResolverLinkedRecordID(): Expected value to be a linked ID, ' +
|
|
460
|
+
'was `%s`.',
|
|
461
|
+
JSON.stringify(id),
|
|
462
|
+
);
|
|
463
|
+
return generateClientObjectClientID(typeName, id);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function getResolverLinkedRecordIDs(
|
|
467
|
+
record: Record,
|
|
468
|
+
typeName: string,
|
|
469
|
+
): ?Array<?DataID> {
|
|
470
|
+
const resolverValue = getValue(record, RELAY_RESOLVER_VALUE_KEY);
|
|
471
|
+
if (resolverValue == null || isSuspenseSentinel(resolverValue)) {
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
invariant(
|
|
475
|
+
Array.isArray(resolverValue),
|
|
476
|
+
'RelayModernRecord.getResolverLinkedRecordIDs(): Expected value to be an array of linked IDs, ' +
|
|
477
|
+
'was `%s`.',
|
|
478
|
+
JSON.stringify(resolverValue),
|
|
479
|
+
);
|
|
480
|
+
return resolverValue.map(id => {
|
|
481
|
+
if (id == null) {
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
484
|
+
// TODD: Deprecate client edges that return just id.
|
|
485
|
+
if (typeof id === 'object') {
|
|
486
|
+
id = id.id;
|
|
487
|
+
}
|
|
488
|
+
invariant(
|
|
489
|
+
typeof id === 'string',
|
|
490
|
+
'RelayModernRecord.getResolverLinkedRecordIDs(): Expected item within resolver linked field to be a DataID, ' +
|
|
491
|
+
'was `%s`.',
|
|
492
|
+
JSON.stringify(id),
|
|
493
|
+
);
|
|
494
|
+
return generateClientObjectClientID(typeName, id);
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
|
|
444
498
|
module.exports = {
|
|
445
499
|
clone,
|
|
446
500
|
copyFields,
|
|
@@ -459,4 +513,6 @@ module.exports = {
|
|
|
459
513
|
update,
|
|
460
514
|
getActorLinkedRecordID,
|
|
461
515
|
setActorLinkedRecordID,
|
|
516
|
+
getResolverLinkedRecordID,
|
|
517
|
+
getResolverLinkedRecordIDs,
|
|
462
518
|
};
|
|
@@ -210,7 +210,6 @@ class RelayPublishQueue implements PublishQueue {
|
|
|
210
210
|
sourceOperation?: OperationDescriptor,
|
|
211
211
|
): $ReadOnlyArray<RequestDescriptor> {
|
|
212
212
|
const runWillClearGcHold =
|
|
213
|
-
// $FlowFixMe[incompatible-type]
|
|
214
213
|
this._appliedOptimisticUpdates === 0 && !!this._gcHold;
|
|
215
214
|
const runIsANoop =
|
|
216
215
|
// this._pendingBackupRebase is true if an applied optimistic
|
|
@@ -271,17 +271,45 @@ class RelayReferenceMarker {
|
|
|
271
271
|
return;
|
|
272
272
|
}
|
|
273
273
|
const resolverRecord = this._recordSource.get(dataID);
|
|
274
|
-
if (resolverRecord
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
274
|
+
if (resolverRecord == null) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
if (field.backingField.isOutputType) {
|
|
278
|
+
// Mark all @outputType record IDs
|
|
279
|
+
const outputTypeRecordIDs = getOutputTypeRecordIDs(resolverRecord);
|
|
280
|
+
if (outputTypeRecordIDs != null) {
|
|
281
|
+
for (const dataID of outputTypeRecordIDs) {
|
|
282
|
+
this._references.add(dataID);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
} else {
|
|
286
|
+
const {linkedField} = field;
|
|
287
|
+
const concreteType = linkedField.concreteType;
|
|
288
|
+
if (concreteType == null) {
|
|
289
|
+
// TODO: Handle retaining abstract client edges to client types.
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
if (linkedField.plural) {
|
|
293
|
+
const dataIDs = RelayModernRecord.getResolverLinkedRecordIDs(
|
|
294
|
+
resolverRecord,
|
|
295
|
+
concreteType,
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
if (dataIDs != null) {
|
|
299
|
+
for (const dataID of dataIDs) {
|
|
300
|
+
if (dataID != null) {
|
|
301
|
+
this._traverse(linkedField, dataID);
|
|
302
|
+
}
|
|
281
303
|
}
|
|
282
304
|
}
|
|
283
305
|
} else {
|
|
284
|
-
|
|
306
|
+
const dataID = RelayModernRecord.getResolverLinkedRecordID(
|
|
307
|
+
resolverRecord,
|
|
308
|
+
concreteType,
|
|
309
|
+
);
|
|
310
|
+
if (dataID != null) {
|
|
311
|
+
this._traverse(linkedField, dataID);
|
|
312
|
+
}
|
|
285
313
|
}
|
|
286
314
|
}
|
|
287
315
|
}
|
|
@@ -310,17 +310,13 @@ class RelayResponseNormalizer {
|
|
|
310
310
|
const fieldKey = getStorageKey(selection, this._variables);
|
|
311
311
|
const handleKey = getHandleStorageKey(selection, this._variables);
|
|
312
312
|
this._handleFieldPayloads.push({
|
|
313
|
-
/* $FlowFixMe[class-object-subtyping] added when improving typing
|
|
314
|
-
* for this parameters */
|
|
315
313
|
args,
|
|
316
314
|
dataID: RelayModernRecord.getDataID(record),
|
|
317
315
|
fieldKey,
|
|
318
316
|
handle: selection.handle,
|
|
319
317
|
handleKey,
|
|
320
318
|
handleArgs: selection.handleArgs
|
|
321
|
-
?
|
|
322
|
-
* for this parameters */
|
|
323
|
-
getArgumentValues(selection.handleArgs, this._variables)
|
|
319
|
+
? getArgumentValues(selection.handleArgs, this._variables)
|
|
324
320
|
: {},
|
|
325
321
|
});
|
|
326
322
|
break;
|
|
@@ -583,6 +583,15 @@ export type LogEvent =
|
|
|
583
583
|
// Are we reading this result from the fragment resource cache?
|
|
584
584
|
+cached: boolean,
|
|
585
585
|
}
|
|
586
|
+
| {
|
|
587
|
+
// Indicates getPendingOperationForFragment identified a pending operation.
|
|
588
|
+
// Useful for measuring how frequently RelayOperationTracker identifies a
|
|
589
|
+
// related operation on which to suspend.
|
|
590
|
+
+name: 'pendingoperation.found',
|
|
591
|
+
+fragment: ReaderFragment,
|
|
592
|
+
+fragmentOwner: RequestDescriptor,
|
|
593
|
+
+pendingOperations: $ReadOnlyArray<RequestDescriptor>,
|
|
594
|
+
}
|
|
586
595
|
| {
|
|
587
596
|
+name: 'network.info',
|
|
588
597
|
+networkRequestId: number,
|
|
@@ -18,10 +18,8 @@ function defaultGetDataID(
|
|
|
18
18
|
typeName: string,
|
|
19
19
|
): mixed {
|
|
20
20
|
if (typeName === VIEWER_TYPE) {
|
|
21
|
-
// $FlowFixMe[prop-missing]
|
|
22
21
|
return fieldValue.id == null ? VIEWER_ID : fieldValue.id;
|
|
23
22
|
}
|
|
24
|
-
// $FlowFixMe[prop-missing]
|
|
25
23
|
return fieldValue.id;
|
|
26
24
|
}
|
|
27
25
|
|
package/util/deepFreeze.js.flow
CHANGED
|
@@ -54,6 +54,16 @@ function getPendingOperationsForFragment(
|
|
|
54
54
|
: `Relay(${pendingOperationName}:${fragmentName})`;
|
|
55
55
|
// $FlowExpectedError[prop-missing] Expando to annotate Promises.
|
|
56
56
|
promise.displayName = promiseDisplayName;
|
|
57
|
+
|
|
58
|
+
// In order to monitor the efficacy of RelayOperationTracker, we log
|
|
59
|
+
// enough information to track whether we are suspending on the fragment
|
|
60
|
+
// owner's operation, or some other operation.
|
|
61
|
+
environment.__log({
|
|
62
|
+
name: 'pendingoperation.found',
|
|
63
|
+
fragment: fragmentNode,
|
|
64
|
+
fragmentOwner,
|
|
65
|
+
pendingOperations,
|
|
66
|
+
});
|
|
57
67
|
return {promise, pendingOperations};
|
|
58
68
|
}
|
|
59
69
|
|