File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ module.exports = function (app, defaults) {
102102
103103 // If we're sideloading, we need to add the includes
104104 if ( ctx . req . isSideloadingRelationships ) {
105- requestedIncludes = ctx . req . remotingContext . args . filter . include
105+ requestedIncludes = utils . setRequestedIncludes ( ctx . req . remotingContext . args . filter . include )
106106 }
107107
108108 if ( model . definition . settings . scope ) {
@@ -119,7 +119,7 @@ module.exports = function (app, defaults) {
119119 if ( typeof include === 'string' ) {
120120 requestedIncludes . push ( include )
121121 } else if ( _ . isArray ( include ) ) {
122- requestedIncludes = requestedIncludes . concat ( include )
122+ requestedIncludes = requestedIncludes . concat ( utils . setRequestedIncludes ( include ) )
123123 }
124124 }
125125
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ module.exports = {
1919 shouldNotApplyJsonApi : shouldNotApplyJsonApi ,
2020 shouldApplyJsonApi : shouldApplyJsonApi ,
2121 relationFkOnModelFrom : relationFkOnModelFrom ,
22+ setRequestedIncludes : setRequestedIncludes ,
2223 setIncludedRelations : setIncludedRelations
2324}
2425
@@ -238,3 +239,21 @@ function setIncludedRelations (relations, app) {
238239 }
239240 return relations
240241}
242+
243+ function setRequestedIncludes ( include ) {
244+ if ( ! include ) return undefined
245+
246+ if ( typeof include === 'string' ) {
247+ return include
248+ }
249+
250+ return include . map ( function ( inc ) {
251+ if ( typeof inc === 'string' ) {
252+ return inc
253+ }
254+
255+ if ( inc instanceof Object ) {
256+ return inc . relation
257+ }
258+ } )
259+ }
You can’t perform that action at this time.
0 commit comments