Function: collectQueryClasses()
function collectQueryClasses(ast): string[];
Defined in: packages/client/src/core/query-engine/classes.ts:41
Collects the class names a parsed query reads.
Deliberately generic: rather than enumerating the node types that can hold a nested
query - scalar_subquery, exists_expr, the right-hand side of IN - it walks the
whole graph and harvests every select node it finds. A new subquery form is then
covered on the day it is added, rather than on the day someone notices a stale list.
Parameters
| Parameter | Type | Description |
|---|---|---|
ast | ( | SelectAST | UnionAST)[] | The ast from ClientStack.query. |
Returns
string[]
The class names read, or null when the query reads a source that is not a
named class. That distinction is the contract: [] means this query reads nothing -
SELECT 1 - and it is safe to subscribe to nothing; null means I cannot account for
this, and the caller should fail open rather than watch an incomplete set.
Example
const { rows, ast } = await stack.query("SELECT * FROM Task JOIN Project ON …");
collectQueryClasses(ast); // ["Task", "Project"]
collectQueryClasses([]); // [] - reads nothing
collectQueryClasses(null); // null - unknown, fail open