relay-runtime 0.0.0-main-141ef0fc → 0.0.0-main-b73f35ea
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/lib/store/RelayReader.js +6 -4
- package/lib/store/ResolverCache.js +2 -2
- package/lib/store/experimental-live-resolvers/LiveResolverCache.js +10 -6
- package/package.json +1 -1
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/RelayReader.js.flow +8 -3
- package/store/ResolverCache.js.flow +3 -3
- package/store/experimental-live-resolvers/LiveResolverCache.js.flow +9 -6
- package/util/ReaderNode.js.flow +3 -1
package/index.js
CHANGED
package/lib/store/RelayReader.js
CHANGED
|
@@ -480,7 +480,9 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
480
480
|
var _field$alias;
|
|
481
481
|
|
|
482
482
|
var resolverModule = field.resolverModule,
|
|
483
|
-
fragment = field.fragment;
|
|
483
|
+
fragment = field.fragment; // Support for languages that work (best) with ES6 modules, such as TypeScript.
|
|
484
|
+
|
|
485
|
+
var resolverFunction = typeof resolverModule === 'function' ? resolverModule : resolverModule["default"];
|
|
484
486
|
var storageKey = getStorageKey(fragment, this._variables);
|
|
485
487
|
var resolverID = ClientID.generateClientID(RelayModernRecord.getDataID(record), storageKey); // Found when reading the resolver fragment, which can happen either when
|
|
486
488
|
// evaluating the resolver and it calls readFragment, or when checking if the
|
|
@@ -522,7 +524,7 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
522
524
|
|
|
523
525
|
try {
|
|
524
526
|
var args = field.args ? getArgumentValues(field.args, _this._variables) : undefined;
|
|
525
|
-
resolverResult =
|
|
527
|
+
resolverResult = resolverFunction( // $FlowFixMe[prop-missing] - Resolver's generated type signature is a lie
|
|
526
528
|
key, // The Relay Compiler enforces that only resolvers that
|
|
527
529
|
// define arguments will have args in the Reader AST.
|
|
528
530
|
// $FlowFixMe[extra-arg]
|
|
@@ -674,10 +676,10 @@ var RelayReader = /*#__PURE__*/function () {
|
|
|
674
676
|
// local within their type. ResolverCache will derive a namespaced ID for us.
|
|
675
677
|
if (field.linkedField.plural) {
|
|
676
678
|
destinationDataID = destinationDataID.map(function (id) {
|
|
677
|
-
return _this2._resolverCache.
|
|
679
|
+
return _this2._resolverCache.ensureClientRecord(id, field.concreteType);
|
|
678
680
|
});
|
|
679
681
|
} else {
|
|
680
|
-
destinationDataID = this._resolverCache.
|
|
682
|
+
destinationDataID = this._resolverCache.ensureClientRecord(destinationDataID, field.concreteType);
|
|
681
683
|
}
|
|
682
684
|
|
|
683
685
|
this._clientEdgeTraversalPath.push(null);
|
|
@@ -56,7 +56,7 @@ var NoopResolverCache = /*#__PURE__*/function () {
|
|
|
56
56
|
|
|
57
57
|
_proto.invalidateDataIDs = function invalidateDataIDs(updatedDataIDs) {};
|
|
58
58
|
|
|
59
|
-
_proto.
|
|
59
|
+
_proto.ensureClientRecord = function ensureClientRecord(id, typeName) {
|
|
60
60
|
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'Client Edges to Client Objects are not supported in this version of Relay Store') : invariant(false) : void 0;
|
|
61
61
|
};
|
|
62
62
|
|
|
@@ -230,7 +230,7 @@ var RecordResolverCache = /*#__PURE__*/function () {
|
|
|
230
230
|
return false;
|
|
231
231
|
};
|
|
232
232
|
|
|
233
|
-
_proto2.
|
|
233
|
+
_proto2.ensureClientRecord = function ensureClientRecord(id, typename) {
|
|
234
234
|
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'Client Edges to Client Objects are not supported in this version of Relay Store') : invariant(false) : void 0;
|
|
235
235
|
};
|
|
236
236
|
|
|
@@ -343,18 +343,22 @@ var LiveResolverCache = /*#__PURE__*/function () {
|
|
|
343
343
|
}
|
|
344
344
|
|
|
345
345
|
return false;
|
|
346
|
-
} //
|
|
347
|
-
// namespaced `__id` field and insert it into
|
|
346
|
+
} // If a given record does not exist, creates an empty record consisting of
|
|
347
|
+
// just an `id` field, along with a namespaced `__id` field and insert it into
|
|
348
|
+
// the store.
|
|
348
349
|
;
|
|
349
350
|
|
|
350
|
-
_proto.
|
|
351
|
+
_proto.ensureClientRecord = function ensureClientRecord(id, typeName) {
|
|
351
352
|
var key = generateClientObjectClientID(typeName, id);
|
|
352
353
|
|
|
353
354
|
var recordSource = this._getRecordSource();
|
|
354
355
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
356
|
+
if (!recordSource.has(key)) {
|
|
357
|
+
var newRecord = RelayModernRecord.create(key, typeName);
|
|
358
|
+
RelayModernRecord.setValue(newRecord, 'id', id);
|
|
359
|
+
recordSource.set(key, newRecord);
|
|
360
|
+
}
|
|
361
|
+
|
|
358
362
|
return key;
|
|
359
363
|
} // Given the set of possible invalidated DataID
|
|
360
364
|
// (Example may be: records from the reverted optimistic update)
|