( query: QueryIR, ref: PropRef, )
| 126 | } |
| 127 | |
| 128 | function getTargetsFromPropRef( |
| 129 | query: QueryIR, |
| 130 | ref: PropRef, |
| 131 | ): Array<LazyLoadTarget> { |
| 132 | if (ref.path.length === 0) { |
| 133 | return [] |
| 134 | } |
| 135 | |
| 136 | if (ref.path.length === 1) { |
| 137 | const field = ref.path[0]! |
| 138 | const selectedField = query.select?.[field] |
| 139 | if (selectedField) { |
| 140 | return getTargetsFromExpression(query, selectedField) |
| 141 | } |
| 142 | return [] |
| 143 | } |
| 144 | |
| 145 | const [alias, ...path] = ref.path |
| 146 | const source = getSourceFromAlias(query, alias!) |
| 147 | if (!source) { |
| 148 | return [] |
| 149 | } |
| 150 | |
| 151 | if (source.type === `collectionRef`) { |
| 152 | return [{ alias: source.alias, collection: source.collection, path }] |
| 153 | } |
| 154 | |
| 155 | if (source.query.limit || source.query.offset) { |
| 156 | return [] |
| 157 | } |
| 158 | |
| 159 | return getTargetsFromQueryRef(source.query, source.alias, ref) |
| 160 | } |
| 161 | |
| 162 | function getSourceFromAlias( |
| 163 | query: QueryIR, |
no test coverage detected