fix(modules-sdk): Fix remote query selection (#6989)

Fix remote query selection for different relations levels as part of a single processed query
This commit is contained in:
Adrien de Peretti
2024-04-07 16:07:31 +02:00
committed by GitHub
parent 4d6306f57b
commit 667c8609cc
4 changed files with 124 additions and 49 deletions

View File

@@ -93,9 +93,11 @@ export class RemoteQuery {
let fields: Set<string> = new Set()
let relations: string[] = []
let shouldSelectAll = false
for (const field of expand.fields ?? []) {
if (field === "*") {
expand.fields = undefined
shouldSelectAll = true
break
}
fields.add(prefix ? `${prefix}.${field}` : field)
@@ -120,7 +122,13 @@ export class RemoteQuery {
}
const allFields = Array.from(fields)
return { select: allFields.length ? allFields : undefined, relations, args }
const select =
allFields.length && !shouldSelectAll
? allFields
: shouldSelectAll
? undefined
: []
return { select, relations, args }
}
private hasPagination(options: { [attr: string]: unknown }): boolean {