@vantreeseba/drizzle-graphql 10.0.1 → 10.0.2
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/dist/index.cjs +38 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1513,11 +1513,44 @@ const extractUniqueKeyFilter = (table, tableName, fieldName, members, value) =>
|
|
|
1513
1513
|
};
|
|
1514
1514
|
//#endregion
|
|
1515
1515
|
//#region src/util/builders/common/relation-filters.ts
|
|
1516
|
-
/**
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1516
|
+
/**
|
|
1517
|
+
* The narrowed contexts already handed out, keyed by the build-scoped base and then by
|
|
1518
|
+
* table. The base is created once per `buildSchema` and the result depends on nothing else,
|
|
1519
|
+
* so every call for one table produces the same value — a `WeakMap` on the base keeps them
|
|
1520
|
+
* for exactly as long as that build is reachable.
|
|
1521
|
+
*/
|
|
1522
|
+
const narrowedCtxCache = /* @__PURE__ */ new WeakMap();
|
|
1523
|
+
/**
|
|
1524
|
+
* Narrows the build-scoped relation filter context to the table a resolver is filtering.
|
|
1525
|
+
*
|
|
1526
|
+
* Cached rather than rebuilt: the base carries the build's whole `tables` and `relationMap`,
|
|
1527
|
+
* and the spread copied both on every call — three per parent row in the lazy relation
|
|
1528
|
+
* resolver, one per parent row in the relation aggregate, and up to four per select, several
|
|
1529
|
+
* of them inside callbacks drizzle invokes lazily.
|
|
1530
|
+
*
|
|
1531
|
+
* The one field written after the fact is `aliases`, the counter that keeps subquery aliases
|
|
1532
|
+
* apart ({@link extractRelationFilter}). Sharing it is what makes the caching safe rather
|
|
1533
|
+
* than a hazard: the counter now spans the process instead of restarting per extraction, and
|
|
1534
|
+
* aliases only ever have to be unique *within* one statement, which a number that never
|
|
1535
|
+
* repeats gives more surely than one that restarts.
|
|
1536
|
+
*/
|
|
1537
|
+
const relationFilterCtx = (base, tableKey) => {
|
|
1538
|
+
if (!base) return;
|
|
1539
|
+
let byTable = narrowedCtxCache.get(base);
|
|
1540
|
+
if (!byTable) {
|
|
1541
|
+
byTable = /* @__PURE__ */ new Map();
|
|
1542
|
+
narrowedCtxCache.set(base, byTable);
|
|
1543
|
+
}
|
|
1544
|
+
let ctx = byTable.get(tableKey);
|
|
1545
|
+
if (!ctx) {
|
|
1546
|
+
ctx = {
|
|
1547
|
+
...base,
|
|
1548
|
+
tableKey
|
|
1549
|
+
};
|
|
1550
|
+
byTable.set(tableKey, ctx);
|
|
1551
|
+
}
|
|
1552
|
+
return ctx;
|
|
1553
|
+
};
|
|
1521
1554
|
/**
|
|
1522
1555
|
* Correlates the parent row with the aliased target table using the relation's own join
|
|
1523
1556
|
* columns. Columns are matched by SQL name rather than object identity so this also works when
|