drizzle-graphql-plus 0.8.38 → 0.8.41

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/index.cjs CHANGED
@@ -30,7 +30,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  ));
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
- // src/export-directive/utils.ts
33
+ // src/export-directive[DEPRECATED]/utils.ts
34
34
  var utils_exports = {};
35
35
  __export(utils_exports, {
36
36
  extractExportDirectives: () => extractExportDirectives,
@@ -39,16 +39,105 @@ __export(utils_exports, {
39
39
  hasExportVariables: () => hasExportVariables,
40
40
  isExportVariable: () => isExportVariable,
41
41
  processExports: () => processExports,
42
- resolveExportVariables: () => resolveExportVariables
42
+ processExportsSync: () => processExportsSync,
43
+ resolveExportVariables: () => resolveExportVariables,
44
+ resolveGraphQLVariables: () => resolveGraphQLVariables
43
45
  });
46
+ async function resolveGraphQLVariables(args, graphqlVariables, info) {
47
+ if (Array.isArray(args)) {
48
+ return Promise.all(
49
+ args.map((item) => resolveGraphQLVariables(item, graphqlVariables, info))
50
+ );
51
+ }
52
+ if (typeof args === "object" && args !== null) {
53
+ const resolved = {};
54
+ for (const [key, value] of Object.entries(args)) {
55
+ if (Array.isArray(value) && value.length === 1 && value[0] === "") {
56
+ let foundUpdatedVariable = false;
57
+ for (const [varName, varValue] of Object.entries(graphqlVariables)) {
58
+ if (Array.isArray(varValue) && varValue.length > 0 && varValue[0] !== "") {
59
+ console.log(`\u{1F50D} Found updated variable ${varName}:`, varValue);
60
+ resolved[key] = varValue;
61
+ foundUpdatedVariable = true;
62
+ break;
63
+ }
64
+ }
65
+ if (!foundUpdatedVariable && info.parentType && (info.parentType.name === "Query" || info.parentType.name === "Mutation")) {
66
+ const context = info.context || {};
67
+ if (context.exportStore) {
68
+ console.log(
69
+ `\u{1F50D} No updated variables yet, checking for pending exports...`
70
+ );
71
+ const potentialExports = Object.keys(graphqlVariables).map(
72
+ (varName) => varName.startsWith("_") ? `$${varName}` : `$_${varName}`
73
+ );
74
+ console.log(
75
+ `\u{1F50D} Potential export names to wait for:`,
76
+ potentialExports
77
+ );
78
+ for (const exportName of potentialExports) {
79
+ try {
80
+ const exportedValue = await context.exportStore.waitFor(
81
+ exportName,
82
+ 2e3,
83
+ false
84
+ );
85
+ if (exportedValue && Array.isArray(exportedValue) && exportedValue.length > 0) {
86
+ console.log(
87
+ `\u2705 Found exported value for ${exportName}:`,
88
+ exportedValue
89
+ );
90
+ resolved[key] = exportedValue;
91
+ foundUpdatedVariable = true;
92
+ break;
93
+ }
94
+ } catch (error) {
95
+ console.log(
96
+ `\u26A0\uFE0F Export ${exportName} not available yet:`,
97
+ error.message
98
+ );
99
+ }
100
+ }
101
+ } else {
102
+ console.log(
103
+ `\u{1F6A8} No export store available in context to wait for exports`
104
+ );
105
+ }
106
+ } else {
107
+ }
108
+ if (!(key in resolved)) {
109
+ resolved[key] = value;
110
+ }
111
+ } else if (typeof value === "object" && value !== null) {
112
+ resolved[key] = await resolveGraphQLVariables(
113
+ value,
114
+ graphqlVariables,
115
+ info
116
+ );
117
+ } else {
118
+ resolved[key] = value;
119
+ }
120
+ }
121
+ return resolved;
122
+ }
123
+ return args;
124
+ }
44
125
  function isExportVariable(value) {
45
- return typeof value === "string" && value.startsWith("$_") && value.length > 2;
126
+ if (typeof value !== "string") {
127
+ return false;
128
+ }
129
+ return value.startsWith("$_") && value.length > 2 || value.startsWith("EXPORT_VAR:") && value.length > 11;
46
130
  }
47
131
  function getVariableName(value) {
48
132
  if (!isExportVariable(value)) {
49
133
  return null;
50
134
  }
51
- return value.slice(2);
135
+ if (value.startsWith("$_")) {
136
+ return value.slice(2);
137
+ } else if (value.startsWith("EXPORT_VAR:")) {
138
+ return value.slice(11);
139
+ }
140
+ return null;
52
141
  }
53
142
  async function resolveExportVariables(args, exportStore, timeout = 5e3) {
54
143
  if (isExportVariable(args)) {
@@ -61,14 +150,19 @@ async function resolveExportVariables(args, exportStore, timeout = 5e3) {
61
150
  args.map(async (item) => {
62
151
  if (isExportVariable(item)) {
63
152
  const varName = getVariableName(item);
64
- return await exportStore.waitFor(varName, timeout, false);
153
+ const resolvedValue = await exportStore.waitFor(
154
+ varName,
155
+ timeout,
156
+ false
157
+ );
158
+ return Array.isArray(resolvedValue) ? resolvedValue : [resolvedValue];
65
159
  } else if (typeof item === "object" && item !== null) {
66
160
  return await resolveExportVariables(item, exportStore, timeout);
67
161
  }
68
162
  return item;
69
163
  })
70
164
  );
71
- return resolved;
165
+ return resolved.flat();
72
166
  }
73
167
  if (typeof args === "object" && args !== null) {
74
168
  const resolved = {};
@@ -151,39 +245,140 @@ function hasExportVariables(args) {
151
245
  }
152
246
  return false;
153
247
  }
154
- function processExports(result, selectionSet, exportStore, isArrayItem = false) {
248
+ async function processExportsSync(result, fieldNode, exportStore, context) {
249
+ if (!result || !fieldNode)
250
+ return;
251
+ const selfExportName = getExportDirective(fieldNode);
252
+ if (selfExportName && result !== void 0 && result !== null) {
253
+ if (!fieldNode.selectionSet) {
254
+ exportStore.set(selfExportName, result);
255
+ } else {
256
+ }
257
+ } else {
258
+ }
259
+ if (fieldNode.selectionSet && result !== void 0 && result !== null) {
260
+ if (Array.isArray(result)) {
261
+ result.forEach((item, index) => {
262
+ if (item && typeof item === "object") {
263
+ processExports(
264
+ item,
265
+ fieldNode.selectionSet,
266
+ exportStore,
267
+ true,
268
+ context
269
+ );
270
+ }
271
+ });
272
+ } else if (typeof result === "object") {
273
+ processExports(
274
+ result,
275
+ fieldNode.selectionSet,
276
+ exportStore,
277
+ false,
278
+ context
279
+ );
280
+ }
281
+ } else {
282
+ }
283
+ }
284
+ function processExports(result, selectionSet, exportStore, isArrayItem = false, context) {
155
285
  if (!result || !selectionSet)
156
286
  return;
157
287
  for (const selection of selectionSet.selections) {
158
288
  if (selection.kind !== "Field")
159
289
  continue;
160
290
  const resultKey = selection.alias?.value ?? selection.name.value;
161
- if (!(resultKey in result))
291
+ if (!(resultKey in result)) {
162
292
  continue;
293
+ }
163
294
  const value = result[resultKey];
295
+ console.log(
296
+ "\u{1F527} Field value:",
297
+ typeof value,
298
+ Array.isArray(value) ? `array[${value.length}]` : "single"
299
+ );
164
300
  const exportName = getExportDirective(selection);
165
301
  if (exportName) {
166
- if (isArrayItem) {
167
- exportStore.accumulate(exportName, value);
302
+ if (exportName.startsWith("$_")) {
303
+ const varName = exportName.slice(2);
304
+ const fullVarName = `_${varName}`;
305
+ console.log(
306
+ `\u{1F527} Updating GraphQL variable '${fullVarName}' with value:`,
307
+ value
308
+ );
309
+ if (context && context._graphqlVariables) {
310
+ const variableValues = context._graphqlVariables;
311
+ console.log(`\u{1F50D} Current variables before update:`, variableValues);
312
+ if (Array.isArray(variableValues[fullVarName]) && variableValues[fullVarName].length === 1 && variableValues[fullVarName][0] === "") {
313
+ variableValues[fullVarName] = [];
314
+ }
315
+ if (isArrayItem) {
316
+ if (Array.isArray(variableValues[fullVarName])) {
317
+ variableValues[fullVarName] = [
318
+ ...variableValues[fullVarName],
319
+ value
320
+ ];
321
+ } else {
322
+ variableValues[fullVarName] = [value];
323
+ }
324
+ } else {
325
+ if (Array.isArray(value)) {
326
+ variableValues[fullVarName] = value;
327
+ } else {
328
+ variableValues[fullVarName] = [value];
329
+ }
330
+ }
331
+ console.log(
332
+ `\u2705 Updated GraphQL variable '${fullVarName}' to:`,
333
+ variableValues[fullVarName]
334
+ );
335
+ } else {
336
+ console.log(
337
+ `\u26A0\uFE0F Could not access GraphQL variables to update '${fullVarName}'`
338
+ );
339
+ }
340
+ if (isArrayItem) {
341
+ exportStore.accumulate(exportName, value);
342
+ } else {
343
+ exportStore.set(exportName, value);
344
+ }
168
345
  } else {
169
- exportStore.set(exportName, value);
346
+ if (isArrayItem) {
347
+ exportStore.accumulate(exportName, value);
348
+ } else {
349
+ console.log(`\u{1F527} Setting ${exportName} with value:`, value);
350
+ exportStore.set(exportName, value);
351
+ }
170
352
  }
353
+ } else {
171
354
  }
172
355
  if (selection.selectionSet && value !== null && value !== void 0) {
173
356
  if (Array.isArray(value)) {
174
357
  value.forEach((item) => {
175
358
  if (item && typeof item === "object") {
176
- processExports(item, selection.selectionSet, exportStore, true);
359
+ processExports(
360
+ item,
361
+ selection.selectionSet,
362
+ exportStore,
363
+ true,
364
+ context
365
+ );
177
366
  }
178
367
  });
179
368
  } else if (typeof value === "object") {
180
- processExports(value, selection.selectionSet, exportStore, isArrayItem);
369
+ processExports(
370
+ value,
371
+ selection.selectionSet,
372
+ exportStore,
373
+ isArrayItem,
374
+ context
375
+ );
181
376
  }
182
377
  }
183
378
  }
184
379
  }
185
380
  var init_utils = __esm({
186
- "src/export-directive/utils.ts"() {
381
+ "src/export-directive[DEPRECATED]/utils.ts"() {
187
382
  "use strict";
188
383
  }
189
384
  });
@@ -192,14 +387,9 @@ var init_utils = __esm({
192
387
  var src_exports = {};
193
388
  __export(src_exports, {
194
389
  ExportStore: () => ExportStore,
195
- SerialExecutor: () => SerialExecutor,
196
390
  buildSchemaSDLWithDataLoader: () => buildSchemaSDL,
197
391
  cleanupDataLoaderContext: () => cleanupDataLoaderContext,
198
392
  createDataLoaderContext: () => createDataLoaderContext,
199
- createExportMiddleware: () => createExportMiddleware,
200
- createExportResolverMap: () => createExportResolverMap,
201
- createSerialMiddleware: () => createSerialMiddleware,
202
- createSerialResolverMap: () => createSerialResolverMap,
203
393
  exportDirectiveTypeDefs: () => exportDirectiveTypeDefs,
204
394
  makeScalarAcceptExports: () => makeScalarAcceptExports,
205
395
  serialDirectiveTypeDefs: () => serialDirectiveTypeDefs,
@@ -207,7 +397,9 @@ __export(src_exports, {
207
397
  setCustomGraphQLTypes: () => setCustomGraphQLTypes,
208
398
  useDataLoaderCleanup: () => useDataLoaderCleanup,
209
399
  useDataLoaderCleanupOnly: () => useDataLoaderCleanupOnly,
210
- useDataLoaderContext: () => useDataLoaderContext
400
+ useDataLoaderContext: () => useDataLoaderContext,
401
+ useExportDirective: () => useExportDirective,
402
+ useSerialDirective: () => useSerialDirective
211
403
  });
212
404
  module.exports = __toCommonJS(src_exports);
213
405
 
@@ -911,8 +1103,8 @@ var RelationDataLoader = class {
911
1103
  const uniqueParentIds = Array.from(new Set(allParentIds));
912
1104
  let resolvedWhere = firstKey.where;
913
1105
  if (resolvedWhere && this.context?.exportStore) {
914
- const { hasExportVariables: hasExportVariables2, resolveExportVariables: resolveExportVariables2 } = await Promise.resolve().then(() => (init_utils(), utils_exports));
915
- if (hasExportVariables2(resolvedWhere)) {
1106
+ const { hasExportVariables: hasExportVariables3, resolveExportVariables: resolveExportVariables3 } = await Promise.resolve().then(() => (init_utils(), utils_exports));
1107
+ if (hasExportVariables3(resolvedWhere)) {
916
1108
  try {
917
1109
  if (this.debugConfig?.exportVariables) {
918
1110
  console.log(
@@ -920,7 +1112,7 @@ var RelationDataLoader = class {
920
1112
  resolvedWhere
921
1113
  );
922
1114
  }
923
- resolvedWhere = await resolveExportVariables2(
1115
+ resolvedWhere = await resolveExportVariables3(
924
1116
  resolvedWhere,
925
1117
  this.context.exportStore
926
1118
  );
@@ -1553,12 +1745,6 @@ var generateMutations = (db, tables, relations, debugConfig) => {
1553
1745
  return { mutations, deleteResultResolvers };
1554
1746
  };
1555
1747
 
1556
- // src/export-directive/directive-definitions.ts
1557
- var exportDirectiveTypeDefs = `directive @export(as: String!) on FIELD`;
1558
-
1559
- // src/serial-directive/directive-definitions.ts
1560
- var serialDirectiveTypeDefs = `directive @serial on QUERY | MUTATION | SUBSCRIPTION`;
1561
-
1562
1748
  // src/build-schema-sdl-with-dl/index.ts
1563
1749
  var import_schema2 = require("@graphql-tools/schema");
1564
1750
  var buildSchemaSDL = (db, config) => {
@@ -1650,185 +1836,165 @@ var useDataLoaderCleanupOnly = () => ({
1650
1836
  })
1651
1837
  });
1652
1838
 
1653
- // src/serial-directive/SerialExecutor.ts
1654
- var SerialExecutor = class {
1655
- executionQueue = /* @__PURE__ */ new Map();
1656
- isEnabled = false;
1657
- /**
1658
- * Enable serial execution for the current operation
1659
- */
1660
- enable() {
1661
- this.isEnabled = true;
1662
- }
1663
- /**
1664
- * Disable serial execution for the current operation
1665
- */
1666
- disable() {
1667
- this.isEnabled = false;
1668
- this.executionQueue.clear();
1669
- }
1670
- /**
1671
- * Check if serial execution is enabled
1672
- */
1673
- isSerialEnabled() {
1674
- return this.isEnabled;
1675
- }
1676
- /**
1677
- * Add a resolver promise to the execution queue
1678
- * @param parentPath - The path of the parent field
1679
- * @param resolverPromise - The resolver promise to queue
1680
- */
1681
- queueResolver(parentPath, resolverPromise) {
1682
- if (!this.isEnabled) {
1683
- return resolverPromise();
1684
- }
1685
- const queue = this.executionQueue.get(parentPath) || [];
1686
- const lastPromise = queue.length > 0 ? queue[queue.length - 1] : null;
1687
- const serialPromise = lastPromise ? lastPromise.then(() => resolverPromise()) : resolverPromise();
1688
- queue.push(serialPromise);
1689
- this.executionQueue.set(parentPath, queue);
1690
- return serialPromise;
1691
- }
1692
- /**
1693
- * Wait for all queued resolvers in a specific path to complete
1694
- * @param parentPath - The path to wait for
1695
- */
1696
- async waitForPath(parentPath) {
1697
- const queue = this.executionQueue.get(parentPath);
1698
- if (queue && queue.length > 0) {
1699
- await Promise.all(queue);
1700
- }
1701
- }
1702
- /**
1703
- * Wait for all queued resolvers to complete
1704
- */
1705
- async waitForAll() {
1706
- const allQueues = Array.from(this.executionQueue.values());
1707
- const allPromises = allQueues.flat();
1708
- if (allPromises.length > 0) {
1709
- await Promise.all(allPromises);
1839
+ // src/serial-directive-envelop-hooks/plugin.ts
1840
+ var import_graphql5 = require("graphql");
1841
+
1842
+ // src/serial-directive-envelop-hooks/utils.ts
1843
+ function hasSerialDirective(document, operationName) {
1844
+ const operation = document.definitions.find((def) => {
1845
+ if (def.kind !== "OperationDefinition")
1846
+ return false;
1847
+ const opDef = def;
1848
+ if (operationName) {
1849
+ return opDef.name?.value === operationName;
1710
1850
  }
1711
- }
1851
+ return true;
1852
+ });
1853
+ if (!operation)
1854
+ return false;
1855
+ return operation.directives?.some(
1856
+ (directive) => directive.name.value === "serial"
1857
+ ) || false;
1858
+ }
1859
+ var SerialExecutor = class {
1860
+ queue = Promise.resolve();
1712
1861
  /**
1713
- * Clear the execution queue for a specific path
1714
- * @param parentPath - The path to clear
1862
+ * Add a task to the execution queue
1863
+ * @param task - Function that returns a promise
1864
+ * @returns Promise that resolves when the task completes
1715
1865
  */
1716
- clearPath(parentPath) {
1717
- this.executionQueue.delete(parentPath);
1866
+ enqueue(task) {
1867
+ const promise = this.queue.then(task, task);
1868
+ this.queue = promise.then(
1869
+ () => {
1870
+ },
1871
+ () => {
1872
+ }
1873
+ );
1874
+ return promise;
1718
1875
  }
1719
1876
  /**
1720
- * Clear all execution queues
1877
+ * Reset the queue
1721
1878
  */
1722
- clearAll() {
1723
- this.executionQueue.clear();
1879
+ reset() {
1880
+ this.queue = Promise.resolve();
1724
1881
  }
1725
1882
  };
1726
-
1727
- // src/serial-directive/utils.ts
1728
- function hasSerialDirective(info) {
1729
- const operation = info.operation;
1730
- return operation.directives?.some(
1731
- (directive) => directive.name.value === "serial"
1732
- ) || false;
1883
+ function createSerialExecutor() {
1884
+ return new SerialExecutor();
1733
1885
  }
1734
- function getFieldPath(info) {
1735
- const path = [];
1736
- let currentPath = info.path;
1737
- while (currentPath) {
1738
- if (typeof currentPath.key === "string") {
1739
- path.unshift(currentPath.key);
1740
- }
1741
- currentPath = currentPath.prev;
1742
- }
1743
- return path.join(".");
1744
- }
1745
- function getParentFieldPath(info) {
1746
- const path = [];
1747
- let currentPath = info.path.prev;
1748
- while (currentPath) {
1749
- if (typeof currentPath.key === "string") {
1750
- path.unshift(currentPath.key);
1751
- }
1752
- currentPath = currentPath.prev;
1753
- }
1754
- return path.join(".") || "root";
1755
- }
1756
- function isRootField(info) {
1757
- return !info.path.prev || info.path.prev.key === void 0;
1758
- }
1759
- function logSerialExecution(message, info, data) {
1886
+ function logSerialExecution(message, data) {
1760
1887
  if (process.env["DEBUG_SERIAL"]) {
1761
- const fieldPath = getFieldPath(info);
1762
- const parentPath = getParentFieldPath(info);
1763
- console.log(`[SERIAL] ${message}`, {
1764
- field: `${info.parentType.name}.${info.fieldName}`,
1765
- fieldPath,
1766
- parentPath,
1767
- operation: info.operation.operation,
1768
- data
1769
- });
1888
+ console.log(`[SERIAL-HOOK] ${message}`, data || "");
1770
1889
  }
1771
1890
  }
1772
1891
 
1773
- // src/serial-directive/middleware.ts
1774
- function createSerialMiddleware() {
1775
- return (next) => {
1776
- return async (source, args, context, info) => {
1777
- if (!context.serialExecutor) {
1778
- context.serialExecutor = new SerialExecutor();
1779
- }
1780
- const serialExecutor = context.serialExecutor;
1781
- const shouldExecuteSerially = hasSerialDirective(info);
1782
- if (shouldExecuteSerially && !serialExecutor.isSerialEnabled()) {
1783
- serialExecutor.enable();
1784
- logSerialExecution("Serial execution enabled for operation", info);
1785
- }
1786
- if (!serialExecutor.isSerialEnabled()) {
1787
- return next(source, args, context, info);
1788
- }
1789
- const parentPath = getParentFieldPath(info);
1790
- const isRoot = isRootField(info);
1791
- logSerialExecution("Queuing resolver execution", info, {
1792
- parentPath,
1793
- isRoot,
1794
- fieldName: info.fieldName
1892
+ // src/serial-directive-envelop-hooks/plugin.ts
1893
+ var processedSchemas = /* @__PURE__ */ new WeakSet();
1894
+ var useSerialDirective = () => {
1895
+ return {
1896
+ onExecute({ args }) {
1897
+ const shouldExecuteSerially = hasSerialDirective(
1898
+ args.document,
1899
+ args.operationName || void 0
1900
+ );
1901
+ if (!shouldExecuteSerially) {
1902
+ return void 0;
1903
+ }
1904
+ logSerialExecution("Serial execution enabled for operation", {
1905
+ operationName: args.operationName
1795
1906
  });
1796
- const resolverPromise = () => {
1797
- logSerialExecution("Executing resolver", info);
1798
- return Promise.resolve(next(source, args, context, info));
1799
- };
1800
- try {
1801
- const result = await serialExecutor.queueResolver(
1802
- parentPath,
1803
- resolverPromise
1804
- );
1805
- logSerialExecution("Resolver execution completed", info);
1806
- return result;
1807
- } catch (error) {
1808
- logSerialExecution("Resolver execution failed", info, { error });
1809
- throw error;
1907
+ if (!args.contextValue) {
1908
+ args.contextValue = {};
1810
1909
  }
1811
- };
1812
- };
1813
- }
1814
- function createSerialResolverMap(resolvers) {
1815
- const serialMiddleware = createSerialMiddleware();
1816
- const wrappedResolvers = {};
1817
- for (const typeName in resolvers) {
1818
- wrappedResolvers[typeName] = {};
1819
- for (const fieldName in resolvers[typeName]) {
1820
- const originalResolver = resolvers[typeName][fieldName];
1821
- if (typeof originalResolver === "function") {
1822
- wrappedResolvers[typeName][fieldName] = serialMiddleware(originalResolver);
1823
- } else {
1824
- wrappedResolvers[typeName][fieldName] = originalResolver;
1910
+ const context = args.contextValue;
1911
+ if (!context.serialExecutor) {
1912
+ context.serialExecutor = createSerialExecutor();
1913
+ }
1914
+ const createWrappedResolver = (originalResolver) => {
1915
+ return (source, fieldArgs, fieldContext, info) => {
1916
+ const ctx = fieldContext;
1917
+ const serialExecutor = ctx.serialExecutor;
1918
+ const isRootField = !info.path.prev || info.path.prev.key === void 0;
1919
+ if (!isRootField || !serialExecutor) {
1920
+ if (originalResolver) {
1921
+ return originalResolver(source, fieldArgs, fieldContext, info);
1922
+ }
1923
+ const fieldName = info.fieldName;
1924
+ return source?.[fieldName];
1925
+ }
1926
+ logSerialExecution("Queuing root field for serial execution", {
1927
+ field: `${info.parentType.name}.${info.fieldName}`
1928
+ });
1929
+ return serialExecutor.enqueue(async () => {
1930
+ logSerialExecution("Executing root field", {
1931
+ field: `${info.parentType.name}.${info.fieldName}`
1932
+ });
1933
+ let result;
1934
+ if (originalResolver) {
1935
+ result = await originalResolver(
1936
+ source,
1937
+ fieldArgs,
1938
+ fieldContext,
1939
+ info
1940
+ );
1941
+ } else {
1942
+ const fieldName = info.fieldName;
1943
+ result = source?.[fieldName];
1944
+ }
1945
+ logSerialExecution("Root field execution completed", {
1946
+ field: `${info.parentType.name}.${info.fieldName}`
1947
+ });
1948
+ return result;
1949
+ });
1950
+ };
1951
+ };
1952
+ if (args.schema && !processedSchemas.has(args.schema)) {
1953
+ processedSchemas.add(args.schema);
1954
+ logSerialExecution("Wrapping schema resolvers for @serial support");
1955
+ const typeMap = args.schema.getTypeMap();
1956
+ for (const typeName in typeMap) {
1957
+ const type = typeMap[typeName];
1958
+ if (type instanceof import_graphql5.GraphQLObjectType && !typeName.startsWith("__")) {
1959
+ const fields = type.getFields();
1960
+ for (const fieldName in fields) {
1961
+ const field = fields[fieldName];
1962
+ if (!field) {
1963
+ continue;
1964
+ }
1965
+ if (field.resolve) {
1966
+ field.resolve = createWrappedResolver(field.resolve);
1967
+ }
1968
+ }
1969
+ }
1970
+ }
1825
1971
  }
1972
+ args.fieldResolver = createWrappedResolver(args.fieldResolver);
1973
+ return {
1974
+ onExecuteDone() {
1975
+ logSerialExecution("Serial execution completed", {
1976
+ operationName: args.operationName
1977
+ });
1978
+ }
1979
+ };
1826
1980
  }
1827
- }
1828
- return wrappedResolvers;
1829
- }
1981
+ };
1982
+ };
1983
+
1984
+ // src/serial-directive-envelop-hooks/directive-definitions.ts
1985
+ var serialDirectiveTypeDefs = `
1986
+ """
1987
+ Forces query fields to execute sequentially instead of in parallel.
1988
+ Root-level fields will execute one after another in the order they appear.
1989
+ Nested fields within each parent will also execute sequentially.
1990
+ """
1991
+ directive @serial on QUERY
1992
+ `;
1993
+
1994
+ // src/export-directive-envelop-hooks/plugin.ts
1995
+ var import_graphql7 = require("graphql");
1830
1996
 
1831
- // src/export-directive/ExportStore.ts
1997
+ // src/export-directive-envelop-hooks/ExportStore.ts
1832
1998
  var ExportStore = class {
1833
1999
  store = /* @__PURE__ */ new Map();
1834
2000
  pending = /* @__PURE__ */ new Map();
@@ -1933,75 +2099,15 @@ var ExportStore = class {
1933
2099
  }
1934
2100
  };
1935
2101
 
1936
- // src/export-directive/middleware.ts
1937
- init_utils();
1938
- function createExportMiddleware() {
1939
- return (next) => {
1940
- return async (source, args, context, info) => {
1941
- if (!context.exportStore) {
1942
- context.exportStore = new ExportStore();
1943
- }
1944
- const exportStore = context.exportStore;
1945
- let resolvedArgs = args;
1946
- if (args && typeof args === "object" && hasExportVariables(args)) {
1947
- try {
1948
- resolvedArgs = await resolveExportVariables(args, exportStore, 1e4);
1949
- } catch (error) {
1950
- throw new Error(
1951
- `Export variable resolution failed in ${info.parentType.name}.${info.fieldName}: ${error instanceof Error ? error.message : String(error)}`
1952
- );
1953
- }
1954
- }
1955
- const result = await next(source, resolvedArgs, context, info);
1956
- const fieldNode = info.fieldNodes[0];
1957
- if (!fieldNode)
1958
- return result;
1959
- const selfExportName = getExportDirective(fieldNode);
1960
- if (selfExportName && result !== void 0 && result !== null) {
1961
- if (Array.isArray(result)) {
1962
- result.forEach((value) => {
1963
- if (value !== void 0 && value !== null) {
1964
- exportStore.accumulate(selfExportName, value);
1965
- }
1966
- });
1967
- } else {
1968
- exportStore.set(selfExportName, result);
1969
- }
1970
- }
1971
- if (fieldNode.selectionSet && result !== void 0 && result !== null) {
1972
- if (Array.isArray(result)) {
1973
- result.forEach((item) => {
1974
- if (item && typeof item === "object") {
1975
- processExports(item, fieldNode.selectionSet, exportStore, true);
1976
- }
1977
- });
1978
- } else if (typeof result === "object") {
1979
- processExports(result, fieldNode.selectionSet, exportStore, false);
1980
- }
1981
- }
1982
- return result;
1983
- };
1984
- };
1985
- }
1986
- function createExportResolverMap() {
1987
- return {
1988
- // Apply to all resolvers (Query.*, Mutation.*, etc.)
1989
- "*.*": [createExportMiddleware()]
1990
- };
1991
- }
1992
-
1993
- // src/export-directive/index.ts
1994
- init_utils();
1995
-
1996
- // src/export-directive/makeScalarAcceptExports.ts
1997
- var import_graphql5 = require("graphql");
2102
+ // src/export-directive-envelop-hooks/utils.ts
2103
+ var import_graphql6 = require("graphql");
1998
2104
  function makeScalarAcceptExports(originalScalar) {
1999
2105
  const config = originalScalar.toConfig();
2000
- return new import_graphql5.GraphQLScalarType({
2106
+ return new import_graphql6.GraphQLScalarType({
2001
2107
  ...config,
2002
2108
  name: config.name,
2003
2109
  // Keep original name to override it in schema
2004
- description: `${config.description} (Wrapped with makeScalarAcceptExports to accept $_ export variables)`,
2110
+ description: config.description + " (Wrapped with makeScalarAcceptExports to accept $_ export variables)",
2005
2111
  serialize: config.serialize,
2006
2112
  parseValue(value) {
2007
2113
  if (typeof value === "string" && (value.startsWith("$_") || value === "")) {
@@ -2013,18 +2119,533 @@ function makeScalarAcceptExports(originalScalar) {
2013
2119
  return value;
2014
2120
  },
2015
2121
  parseLiteral(ast, variables) {
2016
- if (ast.kind === import_graphql5.Kind.STRING) {
2122
+ if (ast.kind === import_graphql6.Kind.STRING) {
2017
2123
  if (ast.value.startsWith("$_") || ast.value === "") {
2018
2124
  return ast.value;
2019
2125
  }
2020
2126
  }
2021
- if (config.parseLiteral) {
2127
+ if (config.parseLiteral && ast) {
2022
2128
  return config.parseLiteral(ast, variables);
2023
2129
  }
2024
2130
  return void 0;
2025
2131
  }
2026
2132
  });
2027
2133
  }
2134
+ function isExportVariable2(value) {
2135
+ if (typeof value !== "string") {
2136
+ return false;
2137
+ }
2138
+ return value.startsWith("$_") && value.length > 2 || value.startsWith("EXPORT_VAR:") && value.length > 11;
2139
+ }
2140
+ function getVariableName2(value) {
2141
+ if (!isExportVariable2(value)) {
2142
+ return null;
2143
+ }
2144
+ if (value.startsWith("$_")) {
2145
+ return value.slice(2);
2146
+ } else if (value.startsWith("EXPORT_VAR:")) {
2147
+ return value.slice(11);
2148
+ }
2149
+ return null;
2150
+ }
2151
+ async function resolveExportVariables2(args, exportStore, timeout = 5e3) {
2152
+ if (isExportVariable2(args)) {
2153
+ const varName = getVariableName2(args);
2154
+ const resolvedValue = await exportStore.waitFor(varName, timeout, false);
2155
+ return resolvedValue;
2156
+ }
2157
+ if (Array.isArray(args)) {
2158
+ const resolved = await Promise.all(
2159
+ args.map(async (item) => {
2160
+ if (isExportVariable2(item)) {
2161
+ const varName = getVariableName2(item);
2162
+ const resolvedValue = await exportStore.waitFor(
2163
+ varName,
2164
+ timeout,
2165
+ false
2166
+ );
2167
+ return Array.isArray(resolvedValue) ? resolvedValue : [resolvedValue];
2168
+ } else if (typeof item === "object" && item !== null) {
2169
+ return await resolveExportVariables2(item, exportStore, timeout);
2170
+ }
2171
+ return item;
2172
+ })
2173
+ );
2174
+ return resolved.flat();
2175
+ }
2176
+ if (typeof args === "object" && args !== null) {
2177
+ const resolved = {};
2178
+ for (const [key, value] of Object.entries(args)) {
2179
+ if (isExportVariable2(value)) {
2180
+ const varName = getVariableName2(value);
2181
+ const resolvedValue = await exportStore.waitFor(
2182
+ varName,
2183
+ timeout,
2184
+ false
2185
+ );
2186
+ resolved[key] = resolvedValue;
2187
+ } else if (typeof value === "object" && value !== null) {
2188
+ resolved[key] = await resolveExportVariables2(
2189
+ value,
2190
+ exportStore,
2191
+ timeout
2192
+ );
2193
+ } else {
2194
+ resolved[key] = value;
2195
+ }
2196
+ }
2197
+ return resolved;
2198
+ }
2199
+ return args;
2200
+ }
2201
+ function getExportDirective2(fieldNode) {
2202
+ if (!fieldNode || !fieldNode.directives) {
2203
+ return null;
2204
+ }
2205
+ const exportDirective = fieldNode.directives.find(
2206
+ (directive) => directive.name.value === "export"
2207
+ );
2208
+ if (!exportDirective) {
2209
+ return null;
2210
+ }
2211
+ const asArg = exportDirective.arguments?.find(
2212
+ (arg) => arg.name.value === "as"
2213
+ );
2214
+ if (!asArg || asArg.value.kind !== "StringValue") {
2215
+ return null;
2216
+ }
2217
+ return asArg.value.value;
2218
+ }
2219
+ function hasExportVariables2(args) {
2220
+ if (isExportVariable2(args)) {
2221
+ return true;
2222
+ }
2223
+ if (Array.isArray(args)) {
2224
+ return args.some((item) => hasExportVariables2(item));
2225
+ }
2226
+ if (typeof args === "object" && args !== null) {
2227
+ for (const value of Object.values(args)) {
2228
+ if (hasExportVariables2(value)) {
2229
+ return true;
2230
+ }
2231
+ }
2232
+ }
2233
+ return false;
2234
+ }
2235
+ function processExports2(result, selectionSet, exportStore, variables, isArrayItem = false) {
2236
+ if (!result || !selectionSet)
2237
+ return;
2238
+ for (const selection of selectionSet.selections) {
2239
+ if (selection.kind !== "Field")
2240
+ continue;
2241
+ const resultKey = selection.alias?.value ?? selection.name.value;
2242
+ if (!(resultKey in result)) {
2243
+ continue;
2244
+ }
2245
+ const value = result[resultKey];
2246
+ const exportName = getExportDirective2(selection);
2247
+ if (exportName) {
2248
+ logExportExecution("Found @export directive: " + exportName, {
2249
+ isArrayItem,
2250
+ value: typeof value
2251
+ });
2252
+ if (isArrayItem) {
2253
+ exportStore.accumulate(exportName, value);
2254
+ } else {
2255
+ exportStore.set(exportName, value);
2256
+ }
2257
+ if (variables && exportName.startsWith("$_")) {
2258
+ const varName = "_" + exportName.slice(2);
2259
+ if (isArrayItem) {
2260
+ if (!variables[varName]) {
2261
+ variables[varName] = [];
2262
+ }
2263
+ if (Array.isArray(variables[varName])) {
2264
+ if (!variables[varName].includes(value)) {
2265
+ variables[varName].push(value);
2266
+ }
2267
+ }
2268
+ } else {
2269
+ variables[varName] = value;
2270
+ }
2271
+ logExportExecution(
2272
+ "Updated GraphQL variable: " + varName,
2273
+ variables[varName]
2274
+ );
2275
+ }
2276
+ }
2277
+ if (selection.selectionSet && value !== null && value !== void 0) {
2278
+ if (Array.isArray(value)) {
2279
+ value.forEach((item) => {
2280
+ if (item && typeof item === "object") {
2281
+ processExports2(
2282
+ item,
2283
+ selection.selectionSet,
2284
+ exportStore,
2285
+ variables,
2286
+ true
2287
+ );
2288
+ }
2289
+ });
2290
+ } else if (typeof value === "object") {
2291
+ processExports2(
2292
+ value,
2293
+ selection.selectionSet,
2294
+ exportStore,
2295
+ variables,
2296
+ isArrayItem
2297
+ );
2298
+ }
2299
+ }
2300
+ }
2301
+ }
2302
+ async function resolveGraphQLVariables2(args, fieldNode, exportStore, timeout = 5e3) {
2303
+ if (!fieldNode.arguments || !args)
2304
+ return;
2305
+ logExportExecution("resolveGraphQLVariables starting", {
2306
+ argsKeys: Object.keys(args)
2307
+ });
2308
+ for (const arg of fieldNode.arguments) {
2309
+ const argName = arg.name.value;
2310
+ if (argName in args) {
2311
+ await traverseASTAndResolve(
2312
+ arg.value,
2313
+ args,
2314
+ argName,
2315
+ exportStore,
2316
+ timeout
2317
+ );
2318
+ } else {
2319
+ logExportExecution("argName not in args", argName);
2320
+ }
2321
+ }
2322
+ }
2323
+ function normalizeFilterOperators(obj) {
2324
+ if (!obj || typeof obj !== "object")
2325
+ return;
2326
+ if (Array.isArray(obj)) {
2327
+ obj.forEach((item) => normalizeFilterOperators(item));
2328
+ return;
2329
+ }
2330
+ for (const key of Object.keys(obj)) {
2331
+ const value = obj[key];
2332
+ if (key === "in" && value !== void 0 && !("inArray" in obj)) {
2333
+ obj.inArray = value;
2334
+ delete obj.in;
2335
+ } else if (value && typeof value === "object") {
2336
+ normalizeFilterOperators(value);
2337
+ }
2338
+ }
2339
+ }
2340
+ async function traverseASTAndResolve(node, parentObj, key, exportStore, timeout) {
2341
+ logExportExecution("traverseASTAndResolve", { kind: node.kind, key });
2342
+ if (node.kind === import_graphql6.Kind.VARIABLE) {
2343
+ const varName = node.name.value;
2344
+ const candidateNames = ["$" + varName, varName];
2345
+ if (varName.startsWith("_")) {
2346
+ candidateNames.push("$" + varName);
2347
+ } else {
2348
+ candidateNames.push("$_" + varName);
2349
+ }
2350
+ const currentValue = parentObj[key];
2351
+ const isDefault = currentValue === void 0 || currentValue === "" || Array.isArray(currentValue) && (currentValue.length === 0 || currentValue.length === 1 && currentValue[0] === "");
2352
+ logExportExecution("Checking variable", {
2353
+ varName,
2354
+ currentValue,
2355
+ isDefault
2356
+ });
2357
+ if (isDefault) {
2358
+ const exportName = "$" + varName;
2359
+ logExportExecution("Waiting for export variable mapping", {
2360
+ varName,
2361
+ exportName
2362
+ });
2363
+ try {
2364
+ const val = await exportStore.waitFor(exportName, timeout, true);
2365
+ if (val !== void 0) {
2366
+ parentObj[key] = val;
2367
+ logExportExecution(
2368
+ "Resolved variable " + varName + " to export " + exportName,
2369
+ val
2370
+ );
2371
+ } else {
2372
+ logExportExecution(
2373
+ "Export variable resolved to undefined (allowed)",
2374
+ exportName
2375
+ );
2376
+ }
2377
+ } catch (e) {
2378
+ logExportExecution(
2379
+ "Timeout waiting for variable " + varName + " as export " + exportName
2380
+ );
2381
+ }
2382
+ }
2383
+ } else if (node.kind === import_graphql6.Kind.OBJECT) {
2384
+ let obj = parentObj[key];
2385
+ if (!obj || typeof obj !== "object") {
2386
+ obj = {};
2387
+ parentObj[key] = obj;
2388
+ }
2389
+ for (const field of node.fields) {
2390
+ const fieldName = field.name.value;
2391
+ await traverseASTAndResolve(
2392
+ field.value,
2393
+ obj,
2394
+ fieldName,
2395
+ exportStore,
2396
+ timeout
2397
+ );
2398
+ }
2399
+ } else if (node.kind === import_graphql6.Kind.LIST) {
2400
+ let list = parentObj[key];
2401
+ if (!Array.isArray(list)) {
2402
+ list = new Array(node.values.length).fill(void 0);
2403
+ parentObj[key] = list;
2404
+ }
2405
+ const len = Math.min(list.length, node.values.length);
2406
+ for (let i = 0; i < len; i++) {
2407
+ await traverseASTAndResolve(
2408
+ node.values[i],
2409
+ list,
2410
+ i,
2411
+ exportStore,
2412
+ timeout
2413
+ );
2414
+ }
2415
+ }
2416
+ }
2417
+ function logExportExecution(message, data) {
2418
+ if (process.env["DEBUG_EXPORT"]) {
2419
+ console.log("[EXPORT-HOOK] " + message, data || "");
2420
+ }
2421
+ }
2422
+
2423
+ // src/export-directive-envelop-hooks/plugin.ts
2424
+ var processedSchemas2 = /* @__PURE__ */ new WeakSet();
2425
+ var useExportDirective = () => {
2426
+ return {
2427
+ onExecute({ args, setExecuteFn }) {
2428
+ if (!args.contextValue) {
2429
+ args.contextValue = {};
2430
+ }
2431
+ const context = args.contextValue;
2432
+ if (!context.exportStore) {
2433
+ context.exportStore = new ExportStore();
2434
+ logExportExecution("Created new ExportStore in context");
2435
+ }
2436
+ const exportStore = context.exportStore;
2437
+ const initialVariables = args.variableValues || {};
2438
+ if (!context._graphqlVariables) {
2439
+ context._graphqlVariables = { ...initialVariables };
2440
+ logExportExecution(
2441
+ "Stored GraphQL variables reference",
2442
+ Object.keys(initialVariables)
2443
+ );
2444
+ }
2445
+ const createWrappedResolver = (originalResolver) => {
2446
+ const valueNodeHasVariable = (node) => {
2447
+ if (node.kind === import_graphql7.Kind.VARIABLE)
2448
+ return true;
2449
+ if (node.kind === import_graphql7.Kind.LIST) {
2450
+ return node.values.some((v) => valueNodeHasVariable(v));
2451
+ }
2452
+ if (node.kind === import_graphql7.Kind.OBJECT) {
2453
+ return node.fields.some((f) => valueNodeHasVariable(f.value));
2454
+ }
2455
+ return false;
2456
+ };
2457
+ return async (source, fieldArgs, fieldContext, info) => {
2458
+ const ctx = fieldContext;
2459
+ const store = ctx.exportStore;
2460
+ const isComments = info.fieldName === "comments" || info.fieldName === "commentFindMany";
2461
+ if (isComments) {
2462
+ logExportExecution("DEBUG Resolver Called", {
2463
+ fieldName: info.fieldName,
2464
+ args: JSON.stringify(fieldArgs),
2465
+ variables: JSON.stringify(ctx._graphqlVariables)
2466
+ });
2467
+ }
2468
+ const fieldNode = info.fieldNodes[0];
2469
+ let currentArgs = fieldArgs;
2470
+ let resolvedArgs = currentArgs;
2471
+ if (currentArgs && typeof currentArgs === "object") {
2472
+ if (fieldNode) {
2473
+ try {
2474
+ await resolveGraphQLVariables2(
2475
+ currentArgs,
2476
+ fieldNode,
2477
+ store,
2478
+ 1e4
2479
+ );
2480
+ } catch (error) {
2481
+ logExportExecution("GraphQL variable resolution failed", error);
2482
+ }
2483
+ }
2484
+ normalizeFilterOperators(currentArgs);
2485
+ if (hasExportVariables2(currentArgs)) {
2486
+ try {
2487
+ resolvedArgs = await resolveExportVariables2(
2488
+ currentArgs,
2489
+ store,
2490
+ 1e4
2491
+ );
2492
+ } catch (error) {
2493
+ throw new Error(
2494
+ "Export variable resolution failed in " + info.parentType.name + "." + info.fieldName + ": " + (error instanceof Error ? error.message : String(error))
2495
+ );
2496
+ }
2497
+ }
2498
+ }
2499
+ if (ctx._graphqlVariables && info.parentType instanceof import_graphql7.GraphQLObjectType && info.fieldName === "userFindMany" && fieldNode && fieldNode.arguments && fieldNode.arguments.some((arg) => valueNodeHasVariable(arg.value))) {
2500
+ const fieldName = fieldNode.name.value;
2501
+ const fieldDef = info.parentType.getFields()[fieldName];
2502
+ if (isComments && !fieldDef) {
2503
+ logExportExecution("DEBUG fieldDef NOT FOUND (post-exports)");
2504
+ }
2505
+ if (fieldDef) {
2506
+ try {
2507
+ if (isComments) {
2508
+ logExportExecution("DEBUG re-calling getArgumentValues", {
2509
+ fieldNodeName: fieldNode.name.value,
2510
+ fieldDefName: fieldDef.name,
2511
+ variablesKeys: Object.keys(ctx._graphqlVariables || {})
2512
+ });
2513
+ }
2514
+ const freshArgsAfterExports = (0, import_graphql7.getArgumentValues)(
2515
+ fieldDef,
2516
+ fieldNode,
2517
+ ctx._graphqlVariables
2518
+ );
2519
+ if (freshArgsAfterExports) {
2520
+ resolvedArgs = freshArgsAfterExports;
2521
+ normalizeFilterOperators(resolvedArgs);
2522
+ if (isComments) {
2523
+ logExportExecution(
2524
+ "DEBUG getArgumentValues result (post-exports)",
2525
+ {
2526
+ freshArgsKeys: Object.keys(freshArgsAfterExports || {}),
2527
+ freshArgs: JSON.stringify(freshArgsAfterExports)
2528
+ }
2529
+ );
2530
+ }
2531
+ }
2532
+ } catch (e) {
2533
+ logExportExecution(
2534
+ "Failed to re-resolve args after exports for " + info.fieldName,
2535
+ e
2536
+ );
2537
+ }
2538
+ }
2539
+ }
2540
+ let result;
2541
+ if (originalResolver) {
2542
+ result = await originalResolver(
2543
+ source,
2544
+ resolvedArgs,
2545
+ fieldContext,
2546
+ info
2547
+ );
2548
+ } else {
2549
+ const fieldName = info.fieldName;
2550
+ result = source?.[fieldName];
2551
+ }
2552
+ if (fieldNode) {
2553
+ const selfExportName = getExportDirective2(fieldNode);
2554
+ if (selfExportName && result !== void 0 && result !== null) {
2555
+ if (!fieldNode.selectionSet) {
2556
+ logExportExecution(
2557
+ "Setting field-level export: " + selfExportName,
2558
+ { value: result }
2559
+ );
2560
+ store.set(selfExportName, result);
2561
+ if (selfExportName.startsWith("$_")) {
2562
+ const varName = "_" + selfExportName.slice(2);
2563
+ if (ctx._graphqlVariables) {
2564
+ const currentVal = ctx._graphqlVariables[varName];
2565
+ if (Array.isArray(currentVal)) {
2566
+ if (!currentVal.includes(result) && result !== "") {
2567
+ currentVal.push(result);
2568
+ }
2569
+ } else {
2570
+ ctx._graphqlVariables[varName] = result;
2571
+ }
2572
+ logExportExecution(
2573
+ "Updated GraphQL variable: " + varName,
2574
+ ctx._graphqlVariables[varName]
2575
+ );
2576
+ }
2577
+ }
2578
+ }
2579
+ }
2580
+ if (fieldNode && fieldNode.selectionSet && result !== void 0 && result !== null) {
2581
+ if (Array.isArray(result)) {
2582
+ result.forEach((item) => {
2583
+ if (item && typeof item === "object") {
2584
+ processExports2(
2585
+ item,
2586
+ fieldNode.selectionSet,
2587
+ store,
2588
+ ctx._graphqlVariables,
2589
+ true
2590
+ );
2591
+ }
2592
+ });
2593
+ } else if (typeof result === "object") {
2594
+ processExports2(
2595
+ result,
2596
+ fieldNode.selectionSet,
2597
+ store,
2598
+ ctx._graphqlVariables,
2599
+ false
2600
+ );
2601
+ }
2602
+ }
2603
+ }
2604
+ return result;
2605
+ };
2606
+ };
2607
+ if (args.schema && !processedSchemas2.has(args.schema)) {
2608
+ processedSchemas2.add(args.schema);
2609
+ logExportExecution("Wrapping schema resolvers");
2610
+ const typeMap = args.schema.getTypeMap();
2611
+ for (const typeName in typeMap) {
2612
+ const type = typeMap[typeName];
2613
+ if (type instanceof import_graphql7.GraphQLObjectType && !typeName.startsWith("__")) {
2614
+ const fields = type.getFields();
2615
+ for (const fieldName in fields) {
2616
+ const field = fields[fieldName];
2617
+ if (!field) {
2618
+ continue;
2619
+ }
2620
+ if (field.resolve) {
2621
+ field.resolve = createWrappedResolver(field.resolve);
2622
+ }
2623
+ }
2624
+ }
2625
+ }
2626
+ }
2627
+ args.fieldResolver = createWrappedResolver(args.fieldResolver);
2628
+ return {
2629
+ onExecuteDone() {
2630
+ logExportExecution("Export execution completed", {
2631
+ exports: exportStore.getAll(),
2632
+ variables: context._graphqlVariables || {}
2633
+ });
2634
+ }
2635
+ };
2636
+ }
2637
+ };
2638
+ };
2639
+
2640
+ // src/export-directive-envelop-hooks/directive-definitions.ts
2641
+ var exportDirectiveTypeDefs = `
2642
+ """
2643
+ Exports a field value for use by other fields in the same query.
2644
+ The exported value can be referenced using the pattern $_variableName or EXPORT_VAR:variableName.
2645
+ Supports accumulation when used on array items.
2646
+ """
2647
+ directive @export(as: String!) on FIELD
2648
+ `;
2028
2649
 
2029
2650
  // src/helpers.ts
2030
2651
  var import_drizzle_orm9 = require("drizzle-orm");
@@ -2056,14 +2677,9 @@ function setCustomGraphQLTypes(table, columnTypes) {
2056
2677
  // Annotate the CommonJS export names for ESM import in node:
2057
2678
  0 && (module.exports = {
2058
2679
  ExportStore,
2059
- SerialExecutor,
2060
2680
  buildSchemaSDLWithDataLoader,
2061
2681
  cleanupDataLoaderContext,
2062
2682
  createDataLoaderContext,
2063
- createExportMiddleware,
2064
- createExportResolverMap,
2065
- createSerialMiddleware,
2066
- createSerialResolverMap,
2067
2683
  exportDirectiveTypeDefs,
2068
2684
  makeScalarAcceptExports,
2069
2685
  serialDirectiveTypeDefs,
@@ -2071,6 +2687,8 @@ function setCustomGraphQLTypes(table, columnTypes) {
2071
2687
  setCustomGraphQLTypes,
2072
2688
  useDataLoaderCleanup,
2073
2689
  useDataLoaderCleanupOnly,
2074
- useDataLoaderContext
2690
+ useDataLoaderContext,
2691
+ useExportDirective,
2692
+ useSerialDirective
2075
2693
  });
2076
2694
  //# sourceMappingURL=index.cjs.map