Store.push(type, data) has been deprecated. Please provide a JSON-API document object as the first and only argument to store.push
I've just updated to ember 1.13.2 and ember-data 1.13.3 and I'm now receiving lots of the deprecation message mentioned in this post's title. I don't know what is causing it to appear and the Ember Inspector's Deprecations tab doesn't show me where in my code the issue is located.
If anyone can explain to me what the message means and what I need to do to resolve it I'd be grateful.
Thanks.
UPDATE:
My custom application 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-on as a different deprecation message explained that the ActiveModelAdapter will no longer be bundled with ember-data as of v2.0.0. However, I have tried my code with both the ember-data adapter and the add on and I get the same deprecation message about Store.push.
There are a few 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 TO 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 does contain the "id" field but the serializer seems unable to find it as we get the error and the models are not populated to the Ember store.
The line that fails is:
// assets/vendor.js
var belongsTo = { id: data.id, type: data.type };
And after putting a watch on the "data" variable where the "id" is being looked for it is "undefined". The "data" variable is defined in the code as:
var data = _normalizeEmbeddedRelationship2.data;
So I don't know if this gives any clues considering all the ember-data changes recently?
I also have a deprecation that may be related to the problem which is:
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 bundled with ember-data as an earlier deprecation message recommended. Not sure if perhaps this add-on is not compatible with ember-data after all the recent updates to it? (just tested this by reverting back to the original bundled adapter and the same error still occurs).