relay-runtime 0.0.0-main-e8cbdbdf → 0.0.0-main-4f3d2d05

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.
@@ -183,13 +183,10 @@ class RelayReader {
183
183
  // implement the interface. If we aren't sure whether the record implements
184
184
  // the interface, that itself constitutes "expected" data being missing.
185
185
  if (isDataExpectedToBePresent && abstractKey != null && record != null) {
186
- const recordType = RelayModernRecord.getType(record);
187
- const typeID = generateTypeID(recordType);
188
- const typeRecord = this._recordSource.get(typeID);
189
- const implementsInterface =
190
- typeRecord != null
191
- ? RelayModernRecord.getValue(typeRecord, abstractKey)
192
- : null;
186
+ const implementsInterface = this._implementsInterface(
187
+ record,
188
+ abstractKey,
189
+ );
193
190
  if (implementsInterface === false) {
194
191
  // Type known to not implement the interface
195
192
  isDataExpectedToBePresent = false;
@@ -375,13 +372,10 @@ class RelayReader {
375
372
  const parentIsWithinUnmatchedTypeRefinement =
376
373
  this._isWithinUnmatchedTypeRefinement;
377
374
 
378
- const typeName = RelayModernRecord.getType(record);
379
- const typeID = generateTypeID(typeName);
380
- const typeRecord = this._recordSource.get(typeID);
381
- const implementsInterface =
382
- typeRecord != null
383
- ? RelayModernRecord.getValue(typeRecord, abstractKey)
384
- : null;
375
+ const implementsInterface = this._implementsInterface(
376
+ record,
377
+ abstractKey,
378
+ );
385
379
  this._isWithinUnmatchedTypeRefinement =
386
380
  parentIsWithinUnmatchedTypeRefinement ||
387
381
  implementsInterface === false;
@@ -984,6 +978,17 @@ class RelayReader {
984
978
  fields: [...this._missingRequiredFields.fields, ...additional.fields],
985
979
  };
986
980
  }
981
+
982
+ _implementsInterface(record: Record, abstractKey: string): ?boolean {
983
+ const typeName = RelayModernRecord.getType(record);
984
+ const typeRecord = this._recordSource.get(generateTypeID(typeName));
985
+ const implementsInterface =
986
+ typeRecord != null
987
+ ? RelayModernRecord.getValue(typeRecord, abstractKey)
988
+ : null;
989
+ // $FlowFixMe Casting record value
990
+ return implementsInterface;
991
+ }
987
992
  }
988
993
 
989
994
  module.exports = {read};