Skip to content

Commit

Permalink
Remove most non-dirty relationships (#1918)
Browse files Browse the repository at this point in the history
## Purpose

When upgrading to ember 3.28, we lost the ability to distinguish between dirty relationships and clean ones when PATCHing a record, so we would send all the relationships. This was a problem because many of the clean relationships in the serializer had null information, which broke the API, because it doesn't like PATCHed relationships with null information. This fixes that by removing any relationship that is just null info in the serializer. We will still sometimes PATCH relationships we don't need to, but the info should be the same and thus not cause problems for the API. 

## Summary of Changes

1. Scan for null relationships in osf-serializer and remove them from the request payload.
  • Loading branch information
brianjgeiger authored Aug 8, 2023
1 parent 0233110 commit 2aa6abf
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/serializers/osf-serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ export default class OsfSerializer extends JSONAPISerializer {
delete serialized.data.attributes![attribute];
}
}
if (serialized.data.relationships) {
for (const key of Object.keys(serialized.data.relationships)) {
const rel = serialized.data.relationships[key];
if (rel === null) {
delete serialized.data.relationships[key];
}
}
}
}

return serialized;
Expand Down

0 comments on commit 2aa6abf

Please sign in to comment.