cardstack / ember-data-fastboot

Serializes and restores the ember-data store for fastboot
MIT License
52 stars 24 forks source link

fix issue with latest Ember Data #9

Closed MartinMalinda closed 7 years ago

MartinMalinda commented 7 years ago

store.mapTypes seems to be undefined on latest Ember Data. This PR introduces different logic to get available model names.

rwjblue commented 7 years ago

@runspired / @stefanpenner - Can one of y'all confirm that mapTyoes was intentionally removed, and that this is a good replacement?

josemarluedke commented 7 years ago

I just tried this solution with ember data 2.12.0 and it doesn't seem to work. It always return an empty array.

Also, I quick search in ember data repo, we can see that there is no definition of getModelTypes, so I was wondering where that method is coming from.

Search: https://github.com/emberjs/data/search?q=getModelTypes&type=Code&utf8=%E2%9C%93

rwjblue commented 7 years ago

https://github.com/emberjs/ember.js/blob/0a74a015925709ad7372670e3d11dbbd5938e506/packages/ember-extension-support/lib/data_adapter.js#L349

MartinMalinda commented 7 years ago

@josemarluedke I added a test repo here: https://github.com/MartinMalinda/ember-model-names. It works correctly there. A model is pushed to store in FastBoot mode and peeked in browser successfully.

Maybe you're running some older Ember.js version?

runspired commented 7 years ago

@rwjblue I don't believe that has been a thing for a very very long time

josemarluedke commented 7 years ago

@MartinMalinda Thanks. I tested again in our application and discovered that this does not work with ember-resolver as of version 3.0.0. However, it does work with older versions.

MartinMalinda commented 7 years ago

The issue is already reported in ember-resolver: https://github.com/ember-cli/ember-resolver/issues/175.

Besides here, getModelTypes is used in ember-admin and also ember-inspector.

The API docs mention The DataAdapter helps a data persistence library interface with tools that debug Ember such as the Ember Extension for Chrome and Firefox..

If DataAdapter should not be used for this usecase, we either have to use private API like Object.keys($E._identityMap._map) or the modelNames will have to be explicitly configured.

MartinMalinda commented 7 years ago

This should work now with Ember-resolver 3.0.1.

simonihmig commented 7 years ago

I can confirm using the fork did fix the issue in a real-world app for me! 👍

topaxi commented 7 years ago

Is there anything left to do here? Ping me if I can help in some way.

ef4 commented 7 years ago

Apologies for the delay, I haven't been working near this addon lately.

@MartinMalinda This PR looks great, you should now have sufficient permissions to merge it and publish to npm.

MartinMalinda commented 7 years ago

Thank you. It's merged, released and published.