Skip to content

Commit c08e537

Browse files
committed
faster iteration of payloads
1 parent f9b9fe2 commit c08e537

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

packages/json-api/src/-private/cache.ts

+6-9
Original file line numberDiff line numberDiff line change
@@ -1973,15 +1973,12 @@ function setupRelationships(
19731973
identifier: StableRecordIdentifier,
19741974
data: ExistingResourceObject
19751975
) {
1976-
// TODO @runspired iterating by definitions instead of by payload keys
1977-
// allows relationship payloads to be ignored silently if no relationship
1978-
// definition exists. Ensure there's a test for this and then consider
1979-
// moving this to an assertion. This check should possibly live in the graph.
1980-
for (const [name, field] of fields) {
1981-
if (!isRelationship(field)) continue;
1982-
1983-
const relationshipData = data.relationships![name];
1984-
if (!relationshipData) continue;
1976+
for (const name in data.relationships!) {
1977+
const relationshipData = data.relationships[name];
1978+
const field = fields.get(name);
1979+
// TODO consider asserting if the relationship is not in the schema
1980+
// we intentionally ignore relationships that are not in the schema
1981+
if (!relationshipData || !field || !isRelationship(field)) continue;
19851982

19861983
graph.push({
19871984
op: 'updateRelationship',

0 commit comments

Comments
 (0)