Recommendations for modelling data relationships #511
-
I'm experimenting with using MSW as a mock layer for a REST API, and so far it's pretty neat! One of the things I'm struggling with is the amount of boilerplate it takes to set up proper data relationships between entities. I know this is one of the points of comparison between MSW and MirageJS (with Mirage being much more geared toward creating relationships between your data). The problem seems to be broken into two responsibilities:
MSW is solving the first problem and has no opinion on how you solve the second. So far, this has me writing my own simple database and corresponding logic to relate entities and return the right objects. It's becoming tedious and I'm imagining having to do this all over again next time I want to use MSW to create a mock server. I find myself asking, "Is it worth it for me to implement a decent portion of an Express server as a mock layer? Is this something I want to do every time I create a new project?" Are there any tools/libraries/patterns that the authors or community are using alongside MSW to handle data modelling and relationships? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hi @schottra, we are working on it. We are creating a data modeling package that can be used with MSW 🥳 . Stay tuned 💯 |
Beta Was this translation helpful? Give feedback.
-
A quick update on the data modeling: we are reaching the moment of a public beta release of the modeling package that's going to be called |
Beta Was this translation helpful? Give feedback.
-
We are excited to announce the @mswjs/data package. You can use that package to model data and defined relationships between the models, as well as generate request handlers for Mock Service Worker. |
Beta Was this translation helpful? Give feedback.
We are excited to announce the @mswjs/data package. You can use that package to model data and defined relationships between the models, as well as generate request handlers for Mock Service Worker.