diff --git a/api/src/database/get-ast-from-query/lib/parse-fields.ts b/api/src/database/get-ast-from-query/lib/parse-fields.ts index f3051cf406..4d8be36e09 100644 --- a/api/src/database/get-ast-from-query/lib/parse-fields.ts +++ b/api/src/database/get-ast-from-query/lib/parse-fields.ts @@ -137,8 +137,14 @@ export async function parseFields( } if (name.includes(':')) { - const [key, scope] = name.split(':'); - relationalStructure[key!] = { [scope!]: [] }; + const [key, scope] = name.split(':') as [string, string]; + + if (key in relationalStructure === false) { + relationalStructure[key] = { [scope]: [] }; + } else if (scope in (relationalStructure[key] as CollectionScope) === false) { + (relationalStructure[key] as CollectionScope)[scope] = []; + } + continue; }