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 CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v0.0.0-main-141ef0fc
2
+ * Relay v0.0.0-main-b73f35ea
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -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 = resolverModule( // $FlowFixMe[prop-missing] - Resolver's generated type signature is a lie
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.createClientRecord(id, field.concreteType);
679
+ return _this2._resolverCache.ensureClientRecord(id, field.concreteType);
678
680
  });
679
681
  } else {
680
- destinationDataID = this._resolverCache.createClientRecord(destinationDataID, field.concreteType);
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.createClientRecord = function createClientRecord(id, typeName) {
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.createClientRecord = function createClientRecord(id, typename) {
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
- } // Create an empty record consisting of just an `id` field, along with a
347
- // namespaced `__id` field and insert it into the store.
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.createClientRecord = function createClientRecord(id, typeName) {
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
- var newRecord = RelayModernRecord.create(key, typeName);
356
- RelayModernRecord.setValue(newRecord, 'id', id);
357
- recordSource.set(key, newRecord);
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)
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": "0.0.0-main-141ef0fc",
4
+ "version": "0.0.0-main-b73f35ea",
5
5
  "keywords": [
6
6
  "graphql",
7
7
  "relay"