Skip to content

Commit

Permalink
Update deserializer-utils.js
Browse files Browse the repository at this point in the history
Ancestry check based on type and id.  Resolve SeyZ#173
  • Loading branch information
FbN authored Sep 30, 2020
1 parent b0315e9 commit 7ae19c2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/deserializer-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = function (jsonapi, data, opts) {
if (included) {
// To prevent circular references, check if the record type
// has already been processed in this thread
if (ancestry.indexOf(included.type) > -1) {
if (ancestry.find((aIncluded) => aIncluded === included.type+':'+included.id)) {
return Promise
.all([extractAttributes(included)])
.then(function (results) {
Expand All @@ -47,7 +47,7 @@ module.exports = function (jsonapi, data, opts) {
}

return Promise
.all([extractAttributes(included), extractRelationships(included, ancestry + ':' + included.type + included.id)])
.all([extractAttributes(included), extractRelationships(included, [...ancestry, included.type + ':' + included.id])])
.then(function (results) {
var attributes = results[0];
var relationships = results[1];
Expand Down Expand Up @@ -146,7 +146,7 @@ module.exports = function (jsonapi, data, opts) {

this.perform = function () {
return Promise
.all([extractAttributes(data), extractRelationships(data, data.type + data.id)])
.all([extractAttributes(data), extractRelationships(data, [data.type + ':' + data.id])])
.then(function (results) {
var attributes = results[0];
var relationships = results[1];
Expand Down

0 comments on commit 7ae19c2

Please sign in to comment.