fix: hydrate relational values - #377
Merged
Merged
Conversation
Member
Author
Released: v1.1.8 🎉This has been released in v1.1.8. Get these changes by running the following command: Predictable release automation by Release. |
noveogroup-amorgunov
added a commit
to noveogroup-amorgunov/nukeapp
that referenced
this pull request
Sep 3, 2026
* refactor: migrate from forked @mswjs/data to @msw/data v1.1.8 - Replace the forked @mswjs/data (feat-persist branch) with the official @msw/data package, which now ships the persist extension with fixed relational hydration (mswjs/data#343, fixed in mswjs/data#377) - Rewrite serverDb to Collection + zod schemas with defineRelations - Add custom persist extension with configurable storage (localStorage/sessionStorage via VITE_API_STORAGE_MODE) and legacy 'mswjs-data/*' storage keys cleanup - Expose dbHydration promise; await migration before starting the MSW worker - Update mock handlers to the new query syntax (q.where predicates) * fix: provide defaults for optional product mock fields Products in the mock data may miss the description and detailsImageUrl keys, but ProductDetailsDto requires them. Add schema defaults so the records always match the DTO contract (the previous nullable fields could be absent, crashing mapProductDetails on detailsImageUrl.length).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
persist/sync strip relational values before storing a record, then restore it via collection.create(), which validates against the schema before relations are initialized. Any required relation is therefore missing at validation time and hydration throws does not match the schema. Existing tests only used .optional() relations, so this went unnoticed.
Changes