Skip to content

fix: support relational updates via array push#358

Merged
kettanaito merged 1 commit intomainfrom
fix/update-via-push
Apr 19, 2026
Merged

fix: support relational updates via array push#358
kettanaito merged 1 commit intomainfrom
fix/update-via-push

Conversation

@kettanaito
Copy link
Copy Markdown
Member

@kettanaito kettanaito commented Apr 19, 2026

(push/splice): mutative can't see through getters (mutative#157).

  • collection.ts — new #buildDraftInput: clones via cloneWithInternals (type-preserving), then overwrites each relation path with the live resolved value (keeps foreign records'
    kPrimaryKey). Passed to createDraft instead of prevRecord.
  • collection.ts — patch loop collapses per-index patches (['posts', N] or ['posts', 'length']) into a single {path: ['posts'], nextValue: } event → reuses Fix A's Many
    handler. Deeper paths (['posts', 0, 'title']) pass through.
  • relation.ts — early hook extended for Many: when next segment is numeric, resolve the indexed foreign record and propagate the trailing path to just that record (was broadcasting to
    all).

@kettanaito kettanaito merged commit 0397d5c into main Apr 19, 2026
1 check passed
@kettanaito kettanaito deleted the fix/update-via-push branch April 19, 2026 14:37
@kettanaito
Copy link
Copy Markdown
Member Author

Released: v1.1.3 🎉

This has been released in v1.1.3.

Get these changes by running the following command:

npm i @msw/data@latest

Predictable release automation by Release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v1.1.2 Not able to use update() to add entry into many() relation

1 participant