@graphql-mesh/transport-sql 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/cjs/adapter.js +60 -0
- package/dist/cjs/batch.js +113 -0
- package/dist/cjs/client.js +205 -0
- package/dist/cjs/client.js.map +7 -0
- package/dist/cjs/dialect.js +60 -0
- package/dist/cjs/dialect.js.map +7 -0
- package/dist/cjs/entity.js +186 -0
- package/dist/cjs/execution.js +307 -0
- package/dist/cjs/execution.js.map +7 -0
- package/dist/cjs/index.js +23 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/mapping.js +260 -0
- package/dist/cjs/mapping.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/pg-executor.js +53 -0
- package/dist/cjs/pg-plans.js +103 -0
- package/dist/cjs/pg-registry.js +239 -0
- package/dist/cjs/plan.js +359 -0
- package/dist/cjs/sql-builder.js +653 -0
- package/dist/cjs/sql-builder.js.map +7 -0
- package/dist/cjs/types.js +0 -0
- package/dist/cjs/types.js.map +7 -0
- package/dist/cjs/uri.js +267 -0
- package/dist/esm/adapter.js +54 -0
- package/dist/esm/batch.js +107 -0
- package/dist/esm/client.js +197 -0
- package/dist/esm/client.js.map +7 -0
- package/dist/esm/dialect.js +54 -0
- package/dist/esm/dialect.js.map +7 -0
- package/dist/esm/entity.js +180 -0
- package/dist/esm/execution.js +303 -0
- package/dist/esm/execution.js.map +7 -0
- package/dist/esm/index.js +20 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/mapping.js +255 -0
- package/dist/esm/mapping.js.map +7 -0
- package/dist/esm/pg-executor.js +49 -0
- package/dist/esm/pg-plans.js +100 -0
- package/dist/esm/pg-registry.js +236 -0
- package/dist/esm/plan.js +351 -0
- package/dist/esm/sql-builder.js +636 -0
- package/dist/esm/sql-builder.js.map +7 -0
- package/dist/esm/types.js +0 -0
- package/dist/esm/types.js.map +7 -0
- package/dist/esm/uri.js +261 -0
- package/dist/package.json +57 -0
- package/dist/typings/adapter.d.cts +9 -0
- package/dist/typings/adapter.d.ts +9 -0
- package/dist/typings/batch.d.cts +21 -0
- package/dist/typings/batch.d.ts +21 -0
- package/dist/typings/client.d.cts +36 -0
- package/dist/typings/client.d.ts +36 -0
- package/dist/typings/dialect.d.cts +9 -0
- package/dist/typings/dialect.d.ts +9 -0
- package/dist/typings/entity.d.cts +24 -0
- package/dist/typings/entity.d.ts +24 -0
- package/dist/typings/execution.d.cts +9 -0
- package/dist/typings/execution.d.ts +9 -0
- package/dist/typings/index.d.cts +15 -0
- package/dist/typings/index.d.ts +15 -0
- package/dist/typings/mapping.d.cts +13 -0
- package/dist/typings/mapping.d.ts +13 -0
- package/dist/typings/pg-executor.d.cts +19 -0
- package/dist/typings/pg-executor.d.ts +19 -0
- package/dist/typings/pg-plans.d.cts +12 -0
- package/dist/typings/pg-plans.d.ts +12 -0
- package/dist/typings/pg-registry.d.cts +16 -0
- package/dist/typings/pg-registry.d.ts +16 -0
- package/dist/typings/plan.d.cts +47 -0
- package/dist/typings/plan.d.ts +47 -0
- package/dist/typings/sql-builder.d.cts +75 -0
- package/dist/typings/sql-builder.d.ts +75 -0
- package/dist/typings/types.d.cts +50 -0
- package/dist/typings/types.d.ts +50 -0
- package/dist/typings/uri.d.cts +42 -0
- package/dist/typings/uri.d.ts +42 -0
- package/package.json +67 -4
- package/src/adapter.ts +56 -0
- package/src/batch.ts +150 -0
- package/src/client.ts +233 -0
- package/src/entity.ts +235 -0
- package/src/execution.ts +411 -0
- package/src/index.ts +25 -0
- package/src/mapping.ts +291 -0
- package/src/pg-executor.ts +68 -0
- package/src/pg-plans.ts +118 -0
- package/src/pg-registry.ts +290 -0
- package/src/plan.ts +466 -0
- package/src/sql-builder.ts +809 -0
- package/src/types.ts +63 -0
- package/src/uri.ts +301 -0
- package/test/client-bun.test.ts +8 -0
- package/test/client.bun.test.ts +46 -0
- package/test/execution.test.ts +277 -0
- package/test/mapping.test.ts +79 -0
- package/test/pg-registry.test.ts +103 -0
- package/test/sql-builder.test.ts +131 -0
- package/test/uri.test.ts +123 -0
- package/README.md +0 -3
package/dist/esm/plan.js
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { getNamedType, isObjectType, Kind, } from 'graphql';
|
|
2
|
+
import { getDefDirectives } from '@graphql-mesh/utils';
|
|
3
|
+
import { batchableEqualityColumn } from './batch.js';
|
|
4
|
+
import { parseSqlMapping } from './mapping.js';
|
|
5
|
+
/** Parent objects stamped with GraphQL field names already satisfied by a JOIN. */
|
|
6
|
+
export const SQL_JOINED_FIELDS = Symbol.for('mesh.sql.joinedFields');
|
|
7
|
+
/**
|
|
8
|
+
* Look ahead in `info` and build a Graphile-style selection plan:
|
|
9
|
+
* - belongs-to (`ROW` + `$this`) → LEFT JOIN chain (including multi-hop)
|
|
10
|
+
* - has-many (`ROWS` + `$this` + simple equality) → correlated JSON subselect
|
|
11
|
+
* (falls back to DataLoader when args/filters make folding unsafe)
|
|
12
|
+
*/
|
|
13
|
+
export function planSelection(schema, info, fullSelection) {
|
|
14
|
+
const parentType = resolveNodeObjectType(info.returnType);
|
|
15
|
+
if (!parentType) {
|
|
16
|
+
return { selection: fullSelection, joins: [], hasMany: [] };
|
|
17
|
+
}
|
|
18
|
+
const fieldNodes = collectObjectFieldNodes(info.fieldNodes, info.fragments, info.returnType);
|
|
19
|
+
const aliasCounter = { n: 0 };
|
|
20
|
+
const joins = [];
|
|
21
|
+
const hasMany = [];
|
|
22
|
+
const neededRootKeys = new Set();
|
|
23
|
+
for (const fieldNode of fieldNodes) {
|
|
24
|
+
if (fieldNode.name.value.startsWith('__'))
|
|
25
|
+
continue;
|
|
26
|
+
const planned = planChildField(schema, parentType, fieldNode, info.fragments, fullSelection, 't', aliasCounter, 0);
|
|
27
|
+
if (!planned)
|
|
28
|
+
continue;
|
|
29
|
+
if (planned.kind === 'belongsTo') {
|
|
30
|
+
joins.push(planned.join);
|
|
31
|
+
neededRootKeys.add(planned.parentGraphqlField);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
hasMany.push(planned.subselect);
|
|
35
|
+
neededRootKeys.add(planned.parentGraphqlField);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const selection = narrowRootSelection(fullSelection, fieldNodes, info.fragments, neededRootKeys);
|
|
39
|
+
return { selection, joins, hasMany };
|
|
40
|
+
}
|
|
41
|
+
/** @deprecated use planSelection */
|
|
42
|
+
export function collectBelongsToJoins(schema, info, parentSelection) {
|
|
43
|
+
return planSelection(schema, info, parentSelection).joins;
|
|
44
|
+
}
|
|
45
|
+
function planChildField(schema, parentType, fieldNode, fragments, parentSelection, parentAlias, aliasCounter, depth) {
|
|
46
|
+
if (depth > 8)
|
|
47
|
+
return null;
|
|
48
|
+
const fieldName = fieldNode.name.value;
|
|
49
|
+
const field = parentType.getFields()[fieldName];
|
|
50
|
+
if (!field)
|
|
51
|
+
return null;
|
|
52
|
+
const sqlArgs = getSqlArgs(schema, field);
|
|
53
|
+
if (!sqlArgs)
|
|
54
|
+
return null;
|
|
55
|
+
const kind = (sqlArgs.kind || 'ROWS');
|
|
56
|
+
const whereMapping = parseSqlMapping(sqlArgs.where);
|
|
57
|
+
const relSelection = parseSqlMapping(sqlArgs.selection);
|
|
58
|
+
const joinColumn = batchableEqualityColumn(whereMapping);
|
|
59
|
+
if (!joinColumn)
|
|
60
|
+
return null;
|
|
61
|
+
const binder = whereMapping.entries.find(e => e.key === joinColumn);
|
|
62
|
+
if (!binder?.value || binder.value.kind !== 'this')
|
|
63
|
+
return null;
|
|
64
|
+
const thisField = binder.value.path?.[0] || binder.value.value;
|
|
65
|
+
if (!thisField)
|
|
66
|
+
return null;
|
|
67
|
+
const parentColEntry = parentSelection.entries.find(e => e.key === thisField);
|
|
68
|
+
const parentColumn = parentColEntry?.value?.kind === 'column' ? parentColEntry.value.value : thisField;
|
|
69
|
+
const childType = unwrapToObjectType(field.type);
|
|
70
|
+
if (kind === 'ROW') {
|
|
71
|
+
const alias = `j${aliasCounter.n++}`;
|
|
72
|
+
const narrowed = narrowSelectionToFieldNodes(relSelection, fieldNode, fragments, childType);
|
|
73
|
+
const nestedJoins = [];
|
|
74
|
+
const neededKeys = new Set();
|
|
75
|
+
if (fieldNode.selectionSet && childType) {
|
|
76
|
+
const childFields = collectFieldNodesFromSelectionSet(fieldNode, fragments);
|
|
77
|
+
for (const childFn of childFields) {
|
|
78
|
+
if (childFn.name.value.startsWith('__'))
|
|
79
|
+
continue;
|
|
80
|
+
const nested = planChildField(schema, childType, childFn, fragments, relSelection, alias, aliasCounter, depth + 1);
|
|
81
|
+
if (nested?.kind === 'belongsTo') {
|
|
82
|
+
nestedJoins.push(nested.join);
|
|
83
|
+
neededKeys.add(nested.parentGraphqlField);
|
|
84
|
+
}
|
|
85
|
+
// Nested has-many under a joined ROW stays on DataLoader (short-circuit only ROW).
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Keep FK columns required by nested joins even if the client didn't ask for them.
|
|
89
|
+
let selection = narrowed.entries.length ? narrowed : relSelection;
|
|
90
|
+
if (neededKeys.size) {
|
|
91
|
+
selection = ensureSelectionKeys(relSelection, selection, neededKeys);
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
kind: 'belongsTo',
|
|
95
|
+
parentGraphqlField: thisField,
|
|
96
|
+
join: {
|
|
97
|
+
fieldName,
|
|
98
|
+
table: String(sqlArgs.table),
|
|
99
|
+
alias,
|
|
100
|
+
parentAlias,
|
|
101
|
+
joinColumn,
|
|
102
|
+
parentColumn,
|
|
103
|
+
selection,
|
|
104
|
+
joins: nestedJoins,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
if (kind === 'ROWS') {
|
|
109
|
+
// Only fold when the only non-planner binder is `$this` equality and args are
|
|
110
|
+
// limited to limit/offset (no filter/orderBy — those stay on DataLoader).
|
|
111
|
+
if (!isSimpleHasManyFoldable(whereMapping, fieldNode))
|
|
112
|
+
return null;
|
|
113
|
+
const limit = readLimitArg(fieldNode);
|
|
114
|
+
const narrowed = narrowSelectionToFieldNodes(relSelection, fieldNode, fragments, childType);
|
|
115
|
+
return {
|
|
116
|
+
kind: 'hasMany',
|
|
117
|
+
parentGraphqlField: thisField,
|
|
118
|
+
subselect: {
|
|
119
|
+
fieldName,
|
|
120
|
+
table: String(sqlArgs.table),
|
|
121
|
+
joinColumn,
|
|
122
|
+
parentGraphqlField: thisField,
|
|
123
|
+
parentColumn,
|
|
124
|
+
selection: narrowed.entries.length ? narrowed : relSelection,
|
|
125
|
+
limit,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
function getSqlArgs(schema, field) {
|
|
132
|
+
const sqlDirs = getDefDirectives(schema, field).filter(d => d.name === 'sql');
|
|
133
|
+
return sqlDirs[0]?.args || null;
|
|
134
|
+
}
|
|
135
|
+
function isSimpleHasManyFoldable(_whereMapping, fieldNode) {
|
|
136
|
+
// Loader always emits filter/orderBy binders; fold only when the operation
|
|
137
|
+
// does not pass those args (limit/offset alone are fine).
|
|
138
|
+
if (fieldNode.arguments?.length) {
|
|
139
|
+
for (const arg of fieldNode.arguments) {
|
|
140
|
+
if (arg.name.value !== 'limit' && arg.name.value !== 'offset')
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
function readLimitArg(fieldNode) {
|
|
147
|
+
const arg = fieldNode.arguments?.find(a => a.name.value === 'limit');
|
|
148
|
+
if (!arg)
|
|
149
|
+
return undefined;
|
|
150
|
+
if (arg.value.kind === Kind.INT)
|
|
151
|
+
return Number(arg.value.value);
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
function ensureSelectionKeys(full, narrowed, keys) {
|
|
155
|
+
const have = new Set(narrowed.entries.map(e => e.key));
|
|
156
|
+
const extra = full.entries.filter(e => keys.has(e.key) && !have.has(e.key));
|
|
157
|
+
if (!extra.length)
|
|
158
|
+
return narrowed;
|
|
159
|
+
return { entries: [...narrowed.entries, ...extra] };
|
|
160
|
+
}
|
|
161
|
+
function narrowRootSelection(full, fieldNodes, fragments, neededKeys) {
|
|
162
|
+
const requested = new Set(neededKeys);
|
|
163
|
+
for (const fn of fieldNodes) {
|
|
164
|
+
if (fn.name.value.startsWith('__'))
|
|
165
|
+
continue;
|
|
166
|
+
// Scalar / enum fields on the object — relations are in neededKeys via FK.
|
|
167
|
+
if (!fn.selectionSet) {
|
|
168
|
+
requested.add(fn.name.value);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
// Client asked for a relation field; FK may already be in neededKeys.
|
|
172
|
+
// Also keep the GraphQL field if it maps to a column (unlikely for relations).
|
|
173
|
+
requested.add(fn.name.value);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (!requested.size)
|
|
177
|
+
return full;
|
|
178
|
+
const entries = full.entries.filter(e => requested.has(e.key) && e.value?.kind === 'column');
|
|
179
|
+
// If narrowing removed everything (only relations selected), keep needed FK columns.
|
|
180
|
+
if (!entries.length) {
|
|
181
|
+
return {
|
|
182
|
+
entries: full.entries.filter(e => neededKeys.has(e.key) && e.value?.kind === 'column'),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
// Always keep needed FK keys
|
|
186
|
+
return ensureSelectionKeys(full, { entries }, neededKeys);
|
|
187
|
+
}
|
|
188
|
+
function unwrapToObjectType(type) {
|
|
189
|
+
const named = getNamedType(type);
|
|
190
|
+
return isObjectType(named) ? named : null;
|
|
191
|
+
}
|
|
192
|
+
/** Object type whose fields are planned (unwraps Relay Connection → node). */
|
|
193
|
+
function resolveNodeObjectType(returnType) {
|
|
194
|
+
const named = getNamedType(returnType);
|
|
195
|
+
if (!isObjectType(named))
|
|
196
|
+
return null;
|
|
197
|
+
if (named.name.endsWith('Connection')) {
|
|
198
|
+
const nodes = named.getFields().nodes;
|
|
199
|
+
if (nodes)
|
|
200
|
+
return unwrapToObjectType(nodes.type);
|
|
201
|
+
const edges = named.getFields().edges;
|
|
202
|
+
if (edges) {
|
|
203
|
+
const edgeType = unwrapToObjectType(edges.type);
|
|
204
|
+
const node = edgeType?.getFields().node;
|
|
205
|
+
if (node)
|
|
206
|
+
return unwrapToObjectType(node.type);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return named;
|
|
210
|
+
}
|
|
211
|
+
function collectObjectFieldNodes(fieldNodes, fragments, returnType) {
|
|
212
|
+
const named = getNamedType(returnType);
|
|
213
|
+
if (!isObjectType(named))
|
|
214
|
+
return [];
|
|
215
|
+
if (named.name.endsWith('Connection') && (named.getFields().nodes || named.getFields().edges)) {
|
|
216
|
+
const out = [];
|
|
217
|
+
for (const fn of fieldNodes) {
|
|
218
|
+
if (!fn.selectionSet)
|
|
219
|
+
continue;
|
|
220
|
+
for (const sel of fn.selectionSet.selections) {
|
|
221
|
+
collectConnectionNodeFields(sel, fragments, out);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return out;
|
|
225
|
+
}
|
|
226
|
+
const out = [];
|
|
227
|
+
for (const fn of fieldNodes) {
|
|
228
|
+
if (!fn.selectionSet)
|
|
229
|
+
continue;
|
|
230
|
+
for (const sel of fn.selectionSet.selections) {
|
|
231
|
+
collectFieldNodes(sel, fragments, out);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return out;
|
|
235
|
+
}
|
|
236
|
+
function collectConnectionNodeFields(sel, fragments, out) {
|
|
237
|
+
if (sel.kind === Kind.FIELD) {
|
|
238
|
+
if (sel.name.value === 'nodes' && sel.selectionSet) {
|
|
239
|
+
for (const s of sel.selectionSet.selections)
|
|
240
|
+
collectFieldNodes(s, fragments, out);
|
|
241
|
+
}
|
|
242
|
+
else if (sel.name.value === 'edges' && sel.selectionSet) {
|
|
243
|
+
for (const edgeSel of sel.selectionSet.selections) {
|
|
244
|
+
if (edgeSel.kind === Kind.FIELD && edgeSel.name.value === 'node' && edgeSel.selectionSet) {
|
|
245
|
+
for (const s of edgeSel.selectionSet.selections)
|
|
246
|
+
collectFieldNodes(s, fragments, out);
|
|
247
|
+
}
|
|
248
|
+
else if (edgeSel.kind === Kind.FRAGMENT_SPREAD || edgeSel.kind === Kind.INLINE_FRAGMENT) {
|
|
249
|
+
collectConnectionNodeFields(edgeSel, fragments, out);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else if (sel.name.value === 'node' && sel.selectionSet) {
|
|
254
|
+
for (const s of sel.selectionSet.selections)
|
|
255
|
+
collectFieldNodes(s, fragments, out);
|
|
256
|
+
}
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (sel.kind === Kind.INLINE_FRAGMENT && sel.selectionSet) {
|
|
260
|
+
for (const s of sel.selectionSet.selections)
|
|
261
|
+
collectConnectionNodeFields(s, fragments, out);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (sel.kind === Kind.FRAGMENT_SPREAD) {
|
|
265
|
+
const frag = fragments[sel.name.value];
|
|
266
|
+
if (frag?.selectionSet) {
|
|
267
|
+
for (const s of frag.selectionSet.selections)
|
|
268
|
+
collectConnectionNodeFields(s, fragments, out);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function collectFieldNodes(sel, fragments, out) {
|
|
273
|
+
if (sel.kind === Kind.FIELD) {
|
|
274
|
+
out.push(sel);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
if (sel.kind === Kind.INLINE_FRAGMENT && sel.selectionSet) {
|
|
278
|
+
for (const s of sel.selectionSet.selections)
|
|
279
|
+
collectFieldNodes(s, fragments, out);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
if (sel.kind === Kind.FRAGMENT_SPREAD) {
|
|
283
|
+
const frag = fragments[sel.name.value];
|
|
284
|
+
if (frag?.selectionSet) {
|
|
285
|
+
for (const s of frag.selectionSet.selections)
|
|
286
|
+
collectFieldNodes(s, fragments, out);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
function collectFieldNodesFromSelectionSet(fieldNode, fragments) {
|
|
291
|
+
const out = [];
|
|
292
|
+
if (!fieldNode.selectionSet)
|
|
293
|
+
return out;
|
|
294
|
+
for (const sel of fieldNode.selectionSet.selections) {
|
|
295
|
+
collectFieldNodes(sel, fragments, out);
|
|
296
|
+
}
|
|
297
|
+
return out;
|
|
298
|
+
}
|
|
299
|
+
function narrowSelectionToFieldNodes(full, fieldNode, fragments, objectType) {
|
|
300
|
+
if (!fieldNode.selectionSet || !objectType)
|
|
301
|
+
return full;
|
|
302
|
+
const requested = new Set();
|
|
303
|
+
const stack = [...fieldNode.selectionSet.selections];
|
|
304
|
+
while (stack.length) {
|
|
305
|
+
const sel = stack.pop();
|
|
306
|
+
if (sel.kind === Kind.FIELD) {
|
|
307
|
+
if (!sel.name.value.startsWith('__'))
|
|
308
|
+
requested.add(sel.name.value);
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
if (sel.kind === Kind.INLINE_FRAGMENT && sel.selectionSet) {
|
|
312
|
+
stack.push(...sel.selectionSet.selections);
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
if (sel.kind === Kind.FRAGMENT_SPREAD) {
|
|
316
|
+
const frag = fragments[sel.name.value];
|
|
317
|
+
if (frag?.selectionSet)
|
|
318
|
+
stack.push(...frag.selectionSet.selections);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (!requested.size)
|
|
322
|
+
return full;
|
|
323
|
+
return {
|
|
324
|
+
entries: full.entries.filter(e => requested.has(e.key) && e.value?.kind === 'column'),
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
export function flattenJoins(joins) {
|
|
328
|
+
const out = [];
|
|
329
|
+
const walk = (list) => {
|
|
330
|
+
for (const j of list) {
|
|
331
|
+
out.push(j);
|
|
332
|
+
if (j.joins?.length)
|
|
333
|
+
walk(j.joins);
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
walk(joins);
|
|
337
|
+
return out;
|
|
338
|
+
}
|
|
339
|
+
export function stampJoinedFields(obj, joins) {
|
|
340
|
+
const names = new Set(joins.map(j => j.fieldName));
|
|
341
|
+
Object.defineProperty(obj, SQL_JOINED_FIELDS, {
|
|
342
|
+
value: names,
|
|
343
|
+
enumerable: false,
|
|
344
|
+
configurable: true,
|
|
345
|
+
});
|
|
346
|
+
return obj;
|
|
347
|
+
}
|
|
348
|
+
export function hasJoinedField(parent, fieldName) {
|
|
349
|
+
const set = parent?.[SQL_JOINED_FIELDS];
|
|
350
|
+
return Boolean(set?.has(fieldName));
|
|
351
|
+
}
|