in packages/relay-runtime/store/RelayExperimentalGraphResponseHandler.js [78:111]
_populateRecord(parentRecord: Record, chunk: DataChunk) {
for (const [key, value] of Object.entries(chunk)) {
switch (key) {
case '$streamID':
case '$kind':
case '__typename':
break;
default:
if (
typeof value !== 'object' ||
value == null ||
Array.isArray(value)
) {
RelayModernRecord.setValue(parentRecord, key, value);
} else {
if (value.hasOwnProperty('__id')) {
// Singular
const streamID = ((value.__id: any): number);
const id = this._lookupCacheKey(streamID);
RelayModernRecord.setLinkedRecordID(parentRecord, key, id);
} else if (value.hasOwnProperty('__ids')) {
// Plural
const streamIDs = ((value.__ids: any): Array<number | null>);
const ids = streamIDs.map(sID => {
return sID == null ? null : this._lookupCacheKey(sID);
});
RelayModernRecord.setLinkedRecordIDs(parentRecord, key, ids);
} else {
invariant(false, 'Expected object to have either __id or __ids.');
}
}
}
}
}