* Walks a Select object to find IncludesSubquery entries. * Plain nested objects still reject includes, but ConditionalSelect branches can * contain guarded nested includes that are only materialized when the branch * condition is true.
(select: Record<string, any>)
| 1761 | * condition is true. |
| 1762 | */ |
| 1763 | function extractIncludesFromSelect(select: Record<string, any>): Array<{ |
| 1764 | key: string |
| 1765 | path: Array<string> |
| 1766 | subquery: IncludesSubquery |
| 1767 | guards: Array<ConditionalSelectGuard> |
| 1768 | }> { |
| 1769 | const results: Array<{ |
| 1770 | key: string |
| 1771 | path: Array<string> |
| 1772 | subquery: IncludesSubquery |
| 1773 | guards: Array<ConditionalSelectGuard> |
| 1774 | }> = [] |
| 1775 | for (const [key, value] of Object.entries(select)) { |
| 1776 | if (key.startsWith(`__SPREAD_SENTINEL__`)) continue |
| 1777 | if (value instanceof IncludesSubquery) { |
| 1778 | results.push({ |
| 1779 | key: getIncludesRoutingKey([key], results), |
| 1780 | path: [key], |
| 1781 | subquery: value, |
| 1782 | guards: [], |
| 1783 | }) |
| 1784 | } else if (value instanceof ConditionalSelect) { |
| 1785 | collectIncludesFromConditionalSelect(value, [key], [], results) |
| 1786 | } else if (isNestedSelectObject(value)) { |
| 1787 | // Check nested objects for IncludesSubquery — not supported yet |
| 1788 | assertNoNestedIncludes(value, key) |
| 1789 | } |
| 1790 | } |
| 1791 | return results |
| 1792 | } |
| 1793 | |
| 1794 | function collectIncludesFromConditionalSelect( |
| 1795 | conditional: ConditionalSelect, |
no test coverage detected