Skip to content

Commit 8f899c5

Browse files
committed
docs(kitsu): add 9.0.0 migration guide
1 parent cbf50df commit 8f899c5

3 files changed

Lines changed: 117 additions & 3 deletions

File tree

packages/kitsu/MIGRATING.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,121 @@
11
# Migration Guides
22

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+
3115
## Migrating to `8.0.0`
4116

117+
Dropped Node 8 suppsort. Lowest supported version is now Node 10.
118+
5119
`kitsu/node` has been removed as it is now identical to`kitsu`.
6120

7121
- Replace `kitsu/node` imports with `kitsu`

packages/kitsu/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
| Package | Package<br> Size\* | Node | Chrome | Firefox | Safari | Edge |
4242
| -------: | :----------------: | :--: | :----: | :-----: | :----: | :--: |
43-
| `kitsu`| ≤ 8.5 kb | 10+ | 79+ | 68+ | 12.1+ | 18+ |
43+
| `kitsu`| ≤ 8.6 kb | 10+ | 79+ | 68+ | 12.1+ | 18+ |
4444

4545
\* Including all dependencies, minified & gzipped
4646

packages/kitsu/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@
5353
"size-limit": [
5454
{
5555
"path": "./lib/index.js",
56-
"limit": "8.6 kb"
56+
"limit": "8.7 kb"
5757
},
5858
{
5959
"path": "./lib/index.mjs",
60-
"limit": "8.6 kb"
60+
"limit": "8.7 kb"
6161
}
6262
],
6363
"gitHead": "5c9778d191d17d7c9790cfc6d0f4e983b4742a53",

0 commit comments

Comments
 (0)