- Notifications
You must be signed in to change notification settings - Fork196
Renders relationship objects even where's no data on included#276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
martinezguillaume commentedJun 13, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
this pr is highly needed & useful ! Is there any way to get it merged ? :) the file diff --git a/node_modules/jsonapi-serializer/lib/deserializer-utils.js b/node_modules/jsonapi-serializer/lib/deserializer-utils.jsindex 1265fd4..480ab81 100644--- a/node_modules/jsonapi-serializer/lib/deserializer-utils.js+++ b/node_modules/jsonapi-serializer/lib/deserializer-utils.js@@ -26,7 +26,7 @@ module.exports = function (jsonapi, data, opts) { function findIncluded(relationshipData, ancestry) { return new Promise(function (resolve) {- if (!jsonapi.included || !relationshipData) { resolve(null); }+ if (!relationshipData) { resolve(null); } var included = _find(jsonapi.included, { id: relationshipData.id,@@ -54,7 +54,7 @@ module.exports = function (jsonapi, data, opts) { resolve(_extend(attributes, relationships)); }); } else {- return resolve(null);+ return resolve({ id: relationshipData.id }); } }); } |
| if(!relationshipData){resolve(null);} | ||
| varincluded=_find(jsonapi.included,{ | ||
| varincluded=_find(jsonapi.included||[],{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
this line is useless, you can call _find withnull orundefined 👍
Uh oh!
There was an error while loading.Please reload this page.
Issue opened with the description of error:#253
When the deserializer receives a relationship without included data, they just ignore it, but sometimes, for performance uses, we just need the object id, and dont want to include the entire object on response data. This solution add an object with just an in on the output of deserializer.