@@ -217,6 +217,10 @@ export class TransformMixinService<T> {
217
217
} ;
218
218
}
219
219
}
220
+ const idNameField =
221
+ table === this . currentResourceName
222
+ ? this . currentPrimaryField
223
+ : this . relationPrimaryField . get ( table ) ;
220
224
for ( const itemRelation of relationList . values ( ) ) {
221
225
const field = camelToKebab ( itemRelation ) ;
222
226
if ( relationships [ itemRelation ] ) {
@@ -226,29 +230,21 @@ export class TransformMixinService<T> {
226
230
links : {
227
231
self : this . getLink (
228
232
urlTable ,
229
- data [ this . relationPrimaryField . get ( table ) ] ,
233
+ data [ idNameField ] ,
230
234
'relationships' ,
231
235
field
232
236
) ,
233
- related : this . getLink (
234
- urlTable ,
235
- data [ this . relationPrimaryField . get ( table ) ] ,
236
- field
237
- ) ,
237
+ related : this . getLink ( urlTable , data [ idNameField ] , field ) ,
238
238
} ,
239
239
} ;
240
240
}
241
- const idNameField =
242
- table === this . currentResourceName
243
- ? this . currentPrimaryField
244
- : this . relationPrimaryField . get ( table ) ;
245
241
return {
246
242
id : data [ idNameField ] . toString ( ) ,
247
243
type : urlTable ,
248
244
attributes,
249
245
relationships,
250
246
links : {
251
- self : this . getLink ( urlTable , data [ 'id' ] ) ,
247
+ self : this . getLink ( urlTable , data [ idNameField ] ) ,
252
248
} ,
253
249
} ;
254
250
}
@@ -273,7 +269,7 @@ export class TransformMixinService<T> {
273
269
: [ itemRow [ field ] ] ;
274
270
275
271
for ( const includeItem of includeArray ) {
276
- const idName = this . relationPrimaryField . get ( field )
272
+ const idName = this . relationPrimaryField . get ( field ) ;
277
273
const id = includeItem [ idName ] ;
278
274
if ( result [ field ] [ id ] ) {
279
275
continue ;
0 commit comments