|
1 | 1 | # Migration Guides |
2 | 2 |
|
| 3 | +## Migrating to `9.0.0` |
| 4 | + |
| 5 | +### Link objects |
| 6 | + |
| 7 | +`kitsu-core` internals have been refactored and `link` objects from root `data` object/array and relationships are now preserved instead of being omitted. |
| 8 | +- Root `data` self links are avaiable as `data.links` or `data[].links` |
| 9 | +- Relationship objects are now `relationshipName.data.id` from `relationshipName.id` |
| 10 | +- Relationship arrays are now `relationshipName.data[].id` from `relationshipName[].id` |
| 11 | +- Relationship links are avaiable as `relationshipName.links` |
| 12 | + |
| 13 | +For the full change in behaviour, see the legacy and new outputs below. |
| 14 | + |
| 15 | +#### Legacy Behaviour |
| 16 | + |
| 17 | +JSON:API Response: |
| 18 | + |
| 19 | +```js |
| 20 | +data: { |
| 21 | + id: '1', |
| 22 | + type: 'libraryEntries' |
| 23 | + links: { |
| 24 | + self: 'https://kitsu.io/api/edge/library-entries/1' |
| 25 | + }, |
| 26 | + attributes: { |
| 27 | + ratingTwenty: 10 |
| 28 | + }, |
| 29 | + relationships: { |
| 30 | + user: { |
| 31 | + links: { |
| 32 | + self: 'https://kitsu.io/api/edge/library-entries/1/relationships/user', |
| 33 | + related: 'https://kitsu.io/api/edge/library-entries/1/user' |
| 34 | + }, |
| 35 | + data: { |
| 36 | + id: '2', |
| 37 | + type: 'users' |
| 38 | + } |
| 39 | + } |
| 40 | + } |
| 41 | +}, |
| 42 | +included: [ |
| 43 | + { |
| 44 | + id: '2', |
| 45 | + type: 'users', |
| 46 | + links: { |
| 47 | + self: 'https://kitsu.io/api/edge/users/2' |
| 48 | + }, |
| 49 | + attributes: { |
| 50 | + name: 'Example' |
| 51 | + } |
| 52 | + } |
| 53 | +``` |
| 54 | + |
| 55 | +Output: |
| 56 | + |
| 57 | +```js |
| 58 | +data: { |
| 59 | + id: '1', |
| 60 | + type: 'libraryEntries', |
| 61 | + ratingTwenty: 10, |
| 62 | + user: { |
| 63 | + id: '2', |
| 64 | + type: 'users', |
| 65 | + name: 'Example' |
| 66 | + } |
| 67 | +} |
| 68 | +``` |
| 69 | + |
| 70 | +#### New Behaviour |
| 71 | + |
| 72 | + |
| 73 | +Output with same JSON:API response data as legacy behaviour: |
| 74 | + |
| 75 | +```js |
| 76 | +data: { |
| 77 | + id: '1', |
| 78 | + type: 'libraryEntries', |
| 79 | + links: { |
| 80 | + self: 'https://kitsu.io/api/edge/library-entries/1' |
| 81 | + }, |
| 82 | + ratingTwenty: 10, |
| 83 | + user: { |
| 84 | + links: { |
| 85 | + self: 'https://kitsu.io/api/edge/library-entries/1/relationships/user', |
| 86 | + related: 'https://kitsu.io/api/edge/library-entries/1/user' |
| 87 | + } |
| 88 | + data: { |
| 89 | + id: '2', |
| 90 | + type: 'users', |
| 91 | + links: { |
| 92 | + self: 'https://kitsu.io/api/edge/users/2' |
| 93 | + }, |
| 94 | + name: 'Example' |
| 95 | + } |
| 96 | + } |
| 97 | +} |
| 98 | +``` |
| 99 | + |
| 100 | +### Non-breaking changes of significance |
| 101 | + |
| 102 | +Accessing relationship resources in requests are now better supported: |
| 103 | + |
| 104 | +```js |
| 105 | +import Kitsu from 'kitsu' |
| 106 | + |
| 107 | +const api = new Kitsu() |
| 108 | + |
| 109 | +api.get('posts/1/comments') |
| 110 | +api.patch('post/1/comments', { id: '1', body: 'An updated comment'}) |
| 111 | +api.post('post/1/comments', { body: 'A new comment'}) |
| 112 | +api.delete('post/1/comments', 1) |
| 113 | +``` |
| 114 | + |
3 | 115 | ## Migrating to `8.0.0` |
4 | 116 |
|
| 117 | +Dropped Node 8 suppsort. Lowest supported version is now Node 10. |
| 118 | + |
5 | 119 | `kitsu/node` has been removed as it is now identical to`kitsu`. |
6 | 120 |
|
7 | 121 | - Replace `kitsu/node` imports with `kitsu` |
|
0 commit comments