How to remove Adapter/Serializer depreciation due to upgrade to latest Ember/Ember-Data


#1

HI, I’m can’t figure how i can remove the deprecated warning in my Ember 1.3.5 project.

In my Adapter i change to the new JSONAPIAdapter :

import DS from 'ember-data';

export default DS.JSONAPIAdapter.extend({
  host: 'http://folio'
});

But i still have warning like this :

"DEPRECATION: Using store.find(type) has been deprecated. Use store.findAll(type) to retrieve all records for a given type. [deprecation id: ds.store.find-with-type-deprecated]
    
"DEPRECATION: The default behavior of shouldReloadAll will change in Ember Data 2.0 to always return false when there is at least one "category" record in the store. If you would like to preserve the current behavior please override shouldReloadAll in your adapter:application and return true. [deprecation id: ds.adapter.should-reload-all-default-behavior]
  
"DEPRECATION: Your custom serializer uses the old version of the Serializer API, with `extract` hooks. Please upgrade your serializers to the new Serializer API using `normalizeResponse` hooks instead. [deprecation id: ds.serializer.extract-hooks-deprecated]

And i have this error when i try to use the adapter :

"Error while processing route: admin.category.index" "payload.map is not a function" "DS.LSSerializer<.extractArray@http://localhost:4200/assets/vendor.js:90474:1

Not sure if deprecations are the cause of this.


#2
  1. Change to findAll like this https://github.com/broerse/ember-cli-blog/blob/master/app/routes/posts.js
  2. To keep the old behavior for shouldReloadAll you can do something like this https://github.com/broerse/ember-cli-blog/blob/master/app/adapters/application.js
  3. I have not seen this serializer deprecation and hope someone else can take a look.

#3

Ok think you, Deprecation go out!


#4

Having the same issue with shouldReloadAll, but adding the return values still does not get rid of the deprecation warnings. Added the below code in my app/adapters/application.js

shouldReloadRecord: function() { return true; }, shouldReloadAll: function() { return true; }, shouldBackgroundReloadRecord: function() { return true; }, shouldBackgroundReloadAll: function() { return true; },

Ember v 1.13.10, Ember Data v 1.13.12

Thanks for your help in advance.


#5

I am still on 1.13.8 without deprecation. I will try to check if they come back in your newer versions. I can take a look at this Sunday.


#6

Thanks so much for getting back. One of the devs in our team found the solution. He added this code in one of the other adapters, not the application adapter.

shouldReloadAll(store, snapshot) { return store.peekAll( snapshot.type.modelName ).get(“length”) <= 0; },


#7

Nice way to fix it. Leaves me some time on Sunday :wink:


#8

I’ve got the same issue number 3 -

"DEPRECATION: Your custom serializer uses the old version of the Serializer API, with extract hooks. Please upgrade your serializers to the new Serializer API using normalizeResponse hooks instead.

Anyone know what I need to change?


#9

oh its very helpful, thank you, thank you very much…


#10

rename typeForRoot(key) { in app\serializers\application.js to modelNameFromPayloadKey(key) {

Basically typeForRoot method is now called as modelNameFromPayloadKey


#11

Thanks. This is project I come back to every now and then. After updating to the next ember version all the depracation warnings disappeared. Sure the warnings are no longer registered but hey, everything still works fine!

I had just been using the default RestSerializer, so I guess thats just been updated.