Skip to content

Commit 5b2c64c

Browse files
pedepwopian
andauthored
fix(kitsu-core): deserialize meta only relationships (#727)
Co-authored-by: James Harris <wopian@wopian.me>
1 parent 87af21b commit 5b2c64c

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

packages/kitsu-core/src/deserialise/index.spec.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,33 @@ describe('kitsu-core', () => {
187187
})
188188
})
189189

190+
it('deserialises relationships with meta', () => {
191+
expect.assertions(1)
192+
expect(deserialise({
193+
data: {
194+
id: '1',
195+
type: 'users',
196+
relationships: {
197+
followers: {
198+
meta: {
199+
follower_count: 200
200+
}
201+
}
202+
}
203+
}
204+
})).toEqual({
205+
data: {
206+
id: '1',
207+
type: 'users',
208+
followers: {
209+
meta: {
210+
follower_count: 200
211+
}
212+
}
213+
}
214+
})
215+
})
216+
190217
it('deserialises relationships with links and data (array)', () => {
191218
expect.assertions(1)
192219

packages/kitsu-core/src/linkRelationships/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ function linkObject (data, included, key, previouslyLinked, relationshipCache) {
8989
function linkAttr (data, key) {
9090
data[key] = {}
9191
if (data.relationships[key].links) data[key].links = data.relationships[key].links
92+
if (data.relationships[key].meta) data[key].meta = data.relationships[key].meta
9293
delete data.relationships[key]
9394
}
9495

0 commit comments

Comments
 (0)