Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Migrating from v3 to v4

Darko Kukovec edited this page Jul 16, 2017 · 5 revisions

The version 4 has five breaking changes:

Removed record baseUrl

The record baseUrl property was removed in favour of the endpoint property. It behaves in the same way (if not set, it will default to the record type). As an additional feature, endpoint can be a function that will be called before each network request.

Failing network requests will always throw with a Response object

In v3, some of the network request would throw with an Error object, and other would resolve with a Response object with the error property.

In v4, all network requests that failed (either because of network errors or JSON API errors) will throw with the Response object with the error property. Depending on the error, the property will contain the Error object or an JSON API error object / array of objects.

Record type and id not exposed as a regular record properties anymore

JSON API spec doesn't prevent a type or id property inside of attributes or relationships and therefore a collision could happen. In v4, the record type and id will be available as getRecordType() and getRecordId() methods.

When creating a record, the second argument can be either the record type or an object with type and id properties.

Updated minimal dependencies

MobX is still a peer dependency, but version 3 is the minimal requirement. mobx-collection-store is now a regular dependency and the minimal required version is 2.

Record snapshot format

The record snapshots are in a different format. If you used them only to serialize/deserialize data everything will continue to work as expected.