Ember JS Deprecation error since upgrade to Ember 1.13.2 and Ember Data 1.13.3

Store.push (type, data) is deprecated. Provide a JSON-API document object as the first and only argument to store.push

I just upgraded to ember 1.13.2 and ember-data 1.13.3 and now I am getting a lot of deprecation messages mentioned in this title. I don't know what is causing it to appear, and the Ember Inspector Deprecations tab doesn't show me where in my code the problem is.

If anyone can explain to me what the message means and what I need to do to resolve it, I would be grateful.

Thank.

UPDATE:

My custom app adapter looks like this:

// app/adapters/application.js
import ActiveModelAdapter from 'active-model-adapter';

export default ActiveModelAdapter.extend({
    host: 'http://dev.mydomain.com',
    namespace: 'api/v1',
});

      

It uses the ActiveModelAdapter add-in as another disclaimer explaining that the ActiveModelAdapter will no longer be bound to ember data from version 2.0. However, I've tried my code with both the ember-data adapter and the append and get the same Store.push disclaimer.

There are multiple stack traces as there are multiple versions of the same deprecation, but here are a couple:

DEPRECATION: store.push(type, data) has been deprecated. Please provide a JSON-API document object as the first and only argument to store.push.
    at ember$data$lib$system$store$$Service.extend.push (http://localhost:4200/assets/vendor.js:81014:17)
    at http://localhost:4200/assets/vendor.js:83253:17
    at Array.forEach (native)
    at Ember.Mixin.create._extractEmbeddedHasMany (http://localhost:4200/assets/vendor.js:83251:68)
    at null.<anonymous> (http://localhost:4200/assets/vendor.js:83219:22)
    at http://localhost:4200/assets/vendor.js:84254:20
    at cb (http://localhost:4200/assets/vendor.js:27380:11)
    at OrderedSet.forEach (http://localhost:4200/assets/vendor.js:27163:11)
    at Map.forEach (http://localhost:4200/assets/vendor.js:27384:18)

DEPRECATION: store.push(type, data) has been deprecated. Please provide a JSON-API document object as the first and only argument to store.push.
    at ember$data$lib$system$store$$Service.extend.push (http://localhost:4200/assets/vendor.js:81014:17)
    at Ember.Mixin.create._extractEmbeddedBelongsTo (http://localhost:4200/assets/vendor.js:83302:15)
    at null.<anonymous> (http://localhost:4200/assets/vendor.js:83226:22)
    at http://localhost:4200/assets/vendor.js:84254:20
    at cb (http://localhost:4200/assets/vendor.js:27380:11)
    at OrderedSet.forEach (http://localhost:4200/assets/vendor.js:27163:11)
    at Map.forEach (http://localhost:4200/assets/vendor.js:27384:18)
    at Function.ember$data$lib$system$model$$default.reopenClass.eachRelationship (http://localhost:4200/assets/vendor.js:84253:83)
    at Ember.Mixin.create._extractEmbeddedRecords (http://localhost:4200/assets/vendor.js:83212:19)

      

NEW ERROR AFTER ADDING isNewSerailizerAPI: true SERIALIZERS (see answers):

Error while processing route: elavonApplication.index Cannot read property 'id' of undefined TypeError: Cannot read property 'id' of undefined
at ember$data$lib$serializers$embedded$records$mixin$$_newExtractEmbeddedBelongsTo (http://localhost:4200/assets/vendor.js:83482:33)
at Ember.Mixin.create._extractEmbeddedBelongsTo (http://localhost:4200/assets/vendor.js:83349:98)
at null.<anonymous> (http://localhost:4200/assets/vendor.js:83419:19)
at http://localhost:4200/assets/vendor.js:84310:20
at Map.forEach.cb (http://localhost:4200/assets/vendor.js:27380:11)
at OrderedSet.forEach (http://localhost:4200/assets/vendor.js:27163:11)
at Map.forEach (http://localhost:4200/assets/vendor.js:27384:18)
at Function.ember$data$lib$system$model$$default.reopenClass.eachRelationship (http://localhost:4200/assets/vendor.js:84309:83)
at ember$data$lib$serializers$embedded$records$mixin$$_newExtractEmbeddedRecords (http://localhost:4200/assets/vendor.js:83413:17)
at Ember.Mixin.create._extractEmbeddedRecords (http://localhost:4200/assets/vendor.js:83265:96)

      

The JSON returned from the server contains an "id" field, but the serializer can't seem to find it as we get an error and the models are not populated in the Ember store.

Invalid line:

// assets/vendor.js
var belongsTo = { id: data.id, type: data.type };

      

And after you put the clock on the "data" variable, where "id" looks for, it's "undefined". The variable "data" is defined in the code as:

var data = _normalizeEmbeddedRelationship2.data;

      

So, I don't know if this gives any clues, given all the changes to the ember data lately?

I also have deprecation which may be related to the problem:

Ember Inspector (Deprecation Trace): 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.
at ember$data$lib$system$store$serializer$response$$normalizeResponseHelper (http://localhost:4200/assets/vendor.js:74034:15)
    at http://localhost:4200/assets/vendor.js:75772:25
    at Object.Backburner.run (http://localhost:4200/assets/vendor.js:10776:25)
    at ember$data$lib$system$store$$Service.extend._adapterRun (http://localhost:4200/assets/vendor.js:81352:33)
    at http://localhost:4200/assets/vendor.js:75771:15
    at tryCatch (http://localhost:4200/assets/vendor.js:65295:14)
    at invokeCallback (http://localhost:4200/assets/vendor.js:65310:15)
    at publish (http://localhost:4200/assets/vendor.js:65278:9)
    at http://localhost:4200/assets/vendor.js:42094:7

      

Also, to reiterate, I am now using the active model adapter add-on instead of the one that was bound to ember-data as the disclaimer recommended earlier. Not sure if this addon is possibly incompatible with ember data after all recent updates? (just by testing this, going back to the original bundled adapter and this same error still occurs).

+3


source to share


3 answers


If you installed:

isNewSerializerAPI: true



In your serializer, this should fix the problem.

+6


source


Ok, the problem seems to have been fixed by the recent update of ember-data 1.13.4. Once I removed our earlier attempt to fix the usage:

isNewSerializerAPI: true

      



on serializers (which caused other issues) and updated to 1.13.4, everything works as it should.

Thanks for the help provided.

0


source


In the release docs, push () now only uses the JSON API compliant payload as the only argument. The type that was used for push is present in the JSON API format, so it is no longer needed separately. For this to work out of the box, your API source would need to return valid JSON API JSON data.

If this is not possible, you will need a custom serializer that implements translation methods to convert the JSON API format to the JSON API format. I think you could do this mostly in the "normalizeResponse" in the Serializer. Details of the transition from the old Serializer API to the new one can be found here in the release docs

0


source







All Articles