Skip to content

Commit e042bd7

Browse files
committed
implement sparse fields for deep includes
1 parent f92fea4 commit e042bd7

File tree

2 files changed

+182
-211
lines changed

2 files changed

+182
-211
lines changed

packages/server/src/api/rest/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,8 +1897,13 @@ class RequestHandler extends APIHandlerBase {
18971897
if (error) return { select: undefined, error };
18981898

18991899
if (i !== parts.length - 1) {
1900-
currPayload[relation] = { include: { ...currPayload[relation]?.include } };
1901-
currPayload = currPayload[relation].include;
1900+
if (select) {
1901+
currPayload[relation] = { select: { ...select } };
1902+
currPayload = currPayload[relation].select;
1903+
} else {
1904+
currPayload[relation] = { include: { ...currPayload[relation]?.include } };
1905+
currPayload = currPayload[relation].include;
1906+
}
19021907
} else {
19031908
currPayload[relation] = select
19041909
? {

0 commit comments

Comments
 (0)