@@ -36,7 +36,7 @@ module.exports = function (jsonapi, data, opts) {
36
36
if ( included ) {
37
37
// To prevent circular references, check if the record type
38
38
// has already been processed in this thread
39
- if ( ancestry . indexOf ( included . type ) > - 1 ) {
39
+ if ( ancestry . find ( ( aIncluded ) => aIncluded === included . type + ':' + included . id ) ) {
40
40
return Promise
41
41
. all ( [ extractAttributes ( included ) ] )
42
42
. then ( function ( results ) {
@@ -47,7 +47,7 @@ module.exports = function (jsonapi, data, opts) {
47
47
}
48
48
49
49
return Promise
50
- . all ( [ extractAttributes ( included ) , extractRelationships ( included , ancestry + ':' + included . type + included . id ) ] )
50
+ . all ( [ extractAttributes ( included ) , extractRelationships ( included , [ ... ancestry , included . type + ':' + included . id ] ) ] )
51
51
. then ( function ( results ) {
52
52
var attributes = results [ 0 ] ;
53
53
var relationships = results [ 1 ] ;
@@ -146,7 +146,7 @@ module.exports = function (jsonapi, data, opts) {
146
146
147
147
this . perform = function ( ) {
148
148
return Promise
149
- . all ( [ extractAttributes ( data ) , extractRelationships ( data , data . type + data . id ) ] )
149
+ . all ( [ extractAttributes ( data ) , extractRelationships ( data , [ data . type + ':' + data . id ] ) ] )
150
150
. then ( function ( results ) {
151
151
var attributes = results [ 0 ] ;
152
152
var relationships = results [ 1 ] ;
0 commit comments