-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What this addon does now that MirageJS has been extracted #2445
Comments
Autodiscovery is (period) bad. I think at most what ember-cli-mirage could do for ember-data is integrate with the schema service and build its models on-demand from the schemas that service provides. But really the mistake mirage is making here is twofold (1) in assuming a library like ember-data has models and (2) in using presentation classes (models) as schema sources (even for itself). Both of these are brittle foundations. One of the points I was trying to convey in my comment is that the future of EmberData has no models. Neither in the container nor on disk. Autodiscovery simply will not work, because there is nothing to discover. EmberData users will likely come up with a lot of ways of supply schema to the schema service (or be schema-less). The encouraged patterns will be around just-in-time derivation/loading. The friction here is probably because EmberData is not an ORM while Mirage attempts to be. |
@runspired I'm really curious about the idea of models going away from EmberData, do you have any more resources you can link to regarding this idea/discussion? |
@hennii I found this blog post a while ago https://blog.lux.name/2-dive-into-ember-data-1/ that is a good introduction. I havent found a part 2 yet, hope it comes eventually. Did a lot of reading from @runspired overview https://blog.emberjs.com/ember-data-5-x-update-2023-04-15/ (Thanks for all the hard work), and am interested in references to how serializers are handled. I do need some property renames for example and not sure where that happens in the request/cache versions. |
@cah-brian-gantzler any data munging to align API to cache format should happen in a handler. That said, such munging always should be considered a code smell if you have the ability to align the cache to the the API or the API to the cache. There are times when neither of these is possible (3rd party API with a format that's not very useful so you want a different cache format anyway) but they are usually rather rare. |
Once MirageJS was extracted to its own repo, the functionality in this repo was left to ember specific features. The way that this addon implemented mirage (for backward compatibility) did not align with the instructions and examples on how to use mirage in the MirageJS documentation.
Over the last year or so the implementation has been changed, exposing things like createServer, to more align the MirageJS documentation with the wya it is implemented in ember. There are more changes to go and this issue points out some of them.
All the documentation in MirageJS shows registering the models and routes when the server is created. The server configuration is not defined the same way for every test (as it is in this addon), but instead each test (or group if in a before each) defines the server with the routes and models that the test needs. (this refers to the quotes point 2 & 3)
What is left that this addon actually does
let me know if I have missed any
Blueprints in point 1 I think are very helpful and definitely and ember thing and should stay
The generic setupMirage was originally built to do all the work behind the scenes with no user interaction. This is the main cause of the problem listed in the every point in the quote. To better align with the MirageJS docs, some of the work was extracted into the config.js function that now creates a server. This function receives a hash that implements feature 4 (which should be extracted to a utility that is called much like discoverEmberDataModels. Feature 3 (discoverEmberDataModels) has been completed extracted to a utility which is called in the make server if needed. setupMirage really just registers a beforeEach in which it creates the hash
Summary of what should stay in this addon and what should not
The text was updated successfully, but these errors were encountered: