diff --git a/src/collections/helpers/build-query.ts b/src/collections/helpers/build-query.ts index ee166ff..e56f9af 100644 --- a/src/collections/helpers/build-query.ts +++ b/src/collections/helpers/build-query.ts @@ -29,11 +29,11 @@ export function buildQuery( const disableChunking = isDefined(limit); - const query = queryFn - ? optionsSelect - ? queryFn(ref).select(...(optionsSelect as string[])) - : queryFn(ref) - : ref; + const baseQuery = queryFn ? queryFn(ref) : ref; + + const query = optionsSelect + ? baseQuery.select(...(optionsSelect as string[])) + : baseQuery; return { query, disableChunking, limit }; }