drizzle-graphql-plus 0.8.37 → 0.8.39

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-tool/utils.ts
33
+ // src/export-directive[DEPRECATED]/utils.ts
34
34
  var utils_exports = {};
35
35
  __export(utils_exports, {
36
36
  extractExportDirectives: () => extractExportDirectives,
@@ -39,60 +39,151 @@ __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
- async function resolveExportVariables(args, exportStore, timeout, allowNull = true) {
142
+ async function resolveExportVariables(args, exportStore, timeout = 5e3) {
54
143
  if (isExportVariable(args)) {
55
144
  const varName = getVariableName(args);
56
- return await exportStore.waitFor(varName, timeout, allowNull);
145
+ const resolvedValue = await exportStore.waitFor(varName, timeout, false);
146
+ return resolvedValue;
57
147
  }
58
148
  if (Array.isArray(args)) {
59
149
  const resolved = await Promise.all(
60
150
  args.map(async (item) => {
61
151
  if (isExportVariable(item)) {
62
152
  const varName = getVariableName(item);
63
- return await exportStore.waitFor(varName, timeout, allowNull);
64
- } else if (typeof item === "object" && item !== null) {
65
- return await resolveExportVariables(
66
- item,
67
- exportStore,
153
+ const resolvedValue = await exportStore.waitFor(
154
+ varName,
68
155
  timeout,
69
- allowNull
156
+ false
70
157
  );
158
+ return Array.isArray(resolvedValue) ? resolvedValue : [resolvedValue];
159
+ } else if (typeof item === "object" && item !== null) {
160
+ return await resolveExportVariables(item, exportStore, timeout);
71
161
  }
72
162
  return item;
73
163
  })
74
164
  );
75
- return resolved;
165
+ return resolved.flat();
76
166
  }
77
167
  if (typeof args === "object" && args !== null) {
78
168
  const resolved = {};
79
169
  for (const [key, value] of Object.entries(args)) {
80
170
  if (isExportVariable(value)) {
81
171
  const varName = getVariableName(value);
82
- resolved[key] = await exportStore.waitFor(varName, timeout, allowNull);
83
- } else if (Array.isArray(value)) {
84
- resolved[key] = await resolveExportVariables(
85
- value,
86
- exportStore,
172
+ const resolvedValue = await exportStore.waitFor(
173
+ varName,
87
174
  timeout,
88
- allowNull
175
+ false
89
176
  );
177
+ if (key === "OR" && Array.isArray(resolvedValue)) {
178
+ resolved[key] = resolvedValue.map((id) => ({ id: { eq: id } }));
179
+ } else {
180
+ resolved[key] = resolvedValue;
181
+ }
90
182
  } else if (typeof value === "object" && value !== null) {
91
183
  resolved[key] = await resolveExportVariables(
92
184
  value,
93
185
  exportStore,
94
- timeout,
95
- allowNull
186
+ timeout
96
187
  );
97
188
  } else {
98
189
  resolved[key] = value;
@@ -154,39 +245,140 @@ function hasExportVariables(args) {
154
245
  }
155
246
  return false;
156
247
  }
157
- 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) {
158
285
  if (!result || !selectionSet)
159
286
  return;
160
287
  for (const selection of selectionSet.selections) {
161
288
  if (selection.kind !== "Field")
162
289
  continue;
163
290
  const resultKey = selection.alias?.value ?? selection.name.value;
164
- if (!(resultKey in result))
291
+ if (!(resultKey in result)) {
165
292
  continue;
293
+ }
166
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
+ );
167
300
  const exportName = getExportDirective(selection);
168
301
  if (exportName) {
169
- if (isArrayItem) {
170
- 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
+ }
171
345
  } else {
172
- 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
+ }
173
352
  }
353
+ } else {
174
354
  }
175
355
  if (selection.selectionSet && value !== null && value !== void 0) {
176
356
  if (Array.isArray(value)) {
177
357
  value.forEach((item) => {
178
358
  if (item && typeof item === "object") {
179
- processExports(item, selection.selectionSet, exportStore, true);
359
+ processExports(
360
+ item,
361
+ selection.selectionSet,
362
+ exportStore,
363
+ true,
364
+ context
365
+ );
180
366
  }
181
367
  });
182
368
  } else if (typeof value === "object") {
183
- processExports(value, selection.selectionSet, exportStore, isArrayItem);
369
+ processExports(
370
+ value,
371
+ selection.selectionSet,
372
+ exportStore,
373
+ isArrayItem,
374
+ context
375
+ );
184
376
  }
185
377
  }
186
378
  }
187
379
  }
188
380
  var init_utils = __esm({
189
- "src/export-tool/utils.ts"() {
381
+ "src/export-directive[DEPRECATED]/utils.ts"() {
190
382
  "use strict";
191
383
  }
192
384
  });
@@ -194,17 +386,20 @@ var init_utils = __esm({
194
386
  // src/index.ts
195
387
  var src_exports = {};
196
388
  __export(src_exports, {
389
+ ExportStore: () => ExportStore,
197
390
  buildSchemaSDLWithDataLoader: () => buildSchemaSDL,
198
391
  cleanupDataLoaderContext: () => cleanupDataLoaderContext,
199
392
  createDataLoaderContext: () => createDataLoaderContext,
200
- createExportMiddleware: () => createExportMiddleware,
201
393
  exportDirectiveTypeDefs: () => exportDirectiveTypeDefs,
202
394
  makeScalarAcceptExports: () => makeScalarAcceptExports,
395
+ serialDirectiveTypeDefs: () => serialDirectiveTypeDefs,
203
396
  setCustomGraphQL: () => setCustomGraphQL,
204
397
  setCustomGraphQLTypes: () => setCustomGraphQLTypes,
205
398
  useDataLoaderCleanup: () => useDataLoaderCleanup,
206
399
  useDataLoaderCleanupOnly: () => useDataLoaderCleanupOnly,
207
- useDataLoaderContext: () => useDataLoaderContext
400
+ useDataLoaderContext: () => useDataLoaderContext,
401
+ useExportDirective: () => useExportDirective,
402
+ useSerialDirective: () => useSerialDirective
208
403
  });
209
404
  module.exports = __toCommonJS(src_exports);
210
405
 
@@ -908,19 +1103,31 @@ var RelationDataLoader = class {
908
1103
  const uniqueParentIds = Array.from(new Set(allParentIds));
909
1104
  let resolvedWhere = firstKey.where;
910
1105
  if (resolvedWhere && this.context?.exportStore) {
911
- const { hasExportVariables: hasExportVariables2, resolveExportVariables: resolveExportVariables2 } = await Promise.resolve().then(() => (init_utils(), utils_exports));
912
- if (hasExportVariables2(resolvedWhere)) {
1106
+ const { hasExportVariables: hasExportVariables3, resolveExportVariables: resolveExportVariables3 } = await Promise.resolve().then(() => (init_utils(), utils_exports));
1107
+ if (hasExportVariables3(resolvedWhere)) {
913
1108
  try {
914
1109
  if (this.debugConfig?.exportVariables) {
915
- console.log(`\u{1F50D} DataLoader: Resolving export variables in where clause:`, resolvedWhere);
1110
+ console.log(
1111
+ `\u{1F50D} DataLoader: Resolving export variables in where clause:`,
1112
+ resolvedWhere
1113
+ );
916
1114
  }
917
- resolvedWhere = await resolveExportVariables2(resolvedWhere, this.context.exportStore);
1115
+ resolvedWhere = await resolveExportVariables3(
1116
+ resolvedWhere,
1117
+ this.context.exportStore
1118
+ );
918
1119
  if (this.debugConfig?.exportVariables) {
919
- console.log(`\u2705 DataLoader: Successfully resolved to:`, resolvedWhere);
1120
+ console.log(
1121
+ `\u2705 DataLoader: Successfully resolved to:`,
1122
+ resolvedWhere
1123
+ );
920
1124
  }
921
1125
  } catch (error) {
922
1126
  if (this.debugConfig?.exportVariables) {
923
- console.warn(`\u274C DataLoader: Failed to resolve export variables:`, error);
1127
+ console.warn(
1128
+ `\u274C DataLoader: Failed to resolve export variables:`,
1129
+ error
1130
+ );
924
1131
  }
925
1132
  }
926
1133
  }
@@ -948,11 +1155,16 @@ var RelationDataLoader = class {
948
1155
  offset: firstKey.offset
949
1156
  });
950
1157
  if (this.debugConfig?.dataLoader) {
951
- console.log(`DataLoader executing query for relation ${firstKey.relationName} with foreign key ${firstKey.foreignKey}`);
1158
+ console.log(
1159
+ `DataLoader executing query for relation ${firstKey.relationName} with foreign key ${firstKey.foreignKey}`
1160
+ );
952
1161
  }
953
1162
  const batchResults = await query;
954
1163
  if (this.debugConfig?.dataLoader) {
955
- console.log(`DataLoader got ${batchResults.length} results:`, batchResults);
1164
+ console.log(
1165
+ `DataLoader got ${batchResults.length} results:`,
1166
+ batchResults
1167
+ );
956
1168
  }
957
1169
  const resultsByParentId = /* @__PURE__ */ new Map();
958
1170
  for (const result of batchResults) {
@@ -963,10 +1175,12 @@ var RelationDataLoader = class {
963
1175
  resultsByParentId.get(parentId).push(result);
964
1176
  }
965
1177
  for (const key of groupKeys) {
966
- const keyResults = key.parentIds.map((parentId) => ({
967
- parentId,
968
- data: resultsByParentId.get(parentId) || []
969
- }));
1178
+ const keyResults = key.parentIds.map(
1179
+ (parentId) => ({
1180
+ parentId,
1181
+ data: resultsByParentId.get(parentId) || []
1182
+ })
1183
+ );
970
1184
  results.push(keyResults);
971
1185
  }
972
1186
  }
@@ -975,7 +1189,9 @@ var RelationDataLoader = class {
975
1189
  buildBatchWhereClause(parentIds, isReversedRelation, foreignKeyName, additionalWhere) {
976
1190
  const foreignKeyColumn = this.tableInfo.columns[foreignKeyName];
977
1191
  if (!foreignKeyColumn) {
978
- console.error(`Foreign key column ${foreignKeyName} not found in table ${this.tableInfo.name}`);
1192
+ console.error(
1193
+ `Foreign key column ${foreignKeyName} not found in table ${this.tableInfo.name}`
1194
+ );
979
1195
  console.error(`Available columns:`, Object.keys(this.tableInfo.columns));
980
1196
  return void 0;
981
1197
  }
@@ -1011,7 +1227,13 @@ function getRelationLoader(context, tableName, queryBase, tableInfo, relations,
1011
1227
  if (!context.relationLoaders.has(tableName)) {
1012
1228
  context.relationLoaders.set(
1013
1229
  tableName,
1014
- new RelationDataLoader(queryBase, tableInfo, relations, context, debugConfig)
1230
+ new RelationDataLoader(
1231
+ queryBase,
1232
+ tableInfo,
1233
+ relations,
1234
+ context,
1235
+ debugConfig
1236
+ )
1015
1237
  // Pass debug config
1016
1238
  );
1017
1239
  }
@@ -1523,9 +1745,6 @@ var generateMutations = (db, tables, relations, debugConfig) => {
1523
1745
  return { mutations, deleteResultResolvers };
1524
1746
  };
1525
1747
 
1526
- // src/export-tool/directive-definitions.ts
1527
- var exportDirectiveTypeDefs = `directive @export(as: String!) on FIELD`;
1528
-
1529
1748
  // src/build-schema-sdl-with-dl/index.ts
1530
1749
  var import_schema2 = require("@graphql-tools/schema");
1531
1750
  var buildSchemaSDL = (db, config) => {
@@ -1617,7 +1836,160 @@ var useDataLoaderCleanupOnly = () => ({
1617
1836
  })
1618
1837
  });
1619
1838
 
1620
- // src/export-tool/ExportStore.ts
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;
1850
+ }
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();
1861
+ /**
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
1865
+ */
1866
+ enqueue(task) {
1867
+ const promise = this.queue.then(task, task);
1868
+ this.queue = promise.then(
1869
+ () => {
1870
+ },
1871
+ () => {
1872
+ }
1873
+ );
1874
+ return promise;
1875
+ }
1876
+ /**
1877
+ * Reset the queue
1878
+ */
1879
+ reset() {
1880
+ this.queue = Promise.resolve();
1881
+ }
1882
+ };
1883
+ function createSerialExecutor() {
1884
+ return new SerialExecutor();
1885
+ }
1886
+ function logSerialExecution(message, data) {
1887
+ if (process.env["DEBUG_SERIAL"]) {
1888
+ console.log(`[SERIAL-HOOK] ${message}`, data || "");
1889
+ }
1890
+ }
1891
+
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
1906
+ });
1907
+ if (!args.contextValue) {
1908
+ args.contextValue = {};
1909
+ }
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(source, fieldArgs, fieldContext, info);
1936
+ } else {
1937
+ const fieldName = info.fieldName;
1938
+ result = source?.[fieldName];
1939
+ }
1940
+ logSerialExecution("Root field execution completed", {
1941
+ field: `${info.parentType.name}.${info.fieldName}`
1942
+ });
1943
+ return result;
1944
+ });
1945
+ };
1946
+ };
1947
+ if (args.schema && !processedSchemas.has(args.schema)) {
1948
+ processedSchemas.add(args.schema);
1949
+ logSerialExecution("Wrapping schema resolvers for @serial support");
1950
+ const typeMap = args.schema.getTypeMap();
1951
+ for (const typeName in typeMap) {
1952
+ const type = typeMap[typeName];
1953
+ if (type instanceof import_graphql5.GraphQLObjectType && !typeName.startsWith("__")) {
1954
+ const fields = type.getFields();
1955
+ for (const fieldName in fields) {
1956
+ const field = fields[fieldName];
1957
+ if (!field) {
1958
+ continue;
1959
+ }
1960
+ if (field.resolve) {
1961
+ field.resolve = createWrappedResolver(field.resolve);
1962
+ }
1963
+ }
1964
+ }
1965
+ }
1966
+ }
1967
+ args.fieldResolver = createWrappedResolver(args.fieldResolver);
1968
+ return {
1969
+ onExecuteDone() {
1970
+ logSerialExecution("Serial execution completed", {
1971
+ operationName: args.operationName
1972
+ });
1973
+ }
1974
+ };
1975
+ }
1976
+ };
1977
+ };
1978
+
1979
+ // src/serial-directive-envelop-hooks/directive-definitions.ts
1980
+ var serialDirectiveTypeDefs = `
1981
+ """
1982
+ Forces query fields to execute sequentially instead of in parallel.
1983
+ Root-level fields will execute one after another in the order they appear.
1984
+ Nested fields within each parent will also execute sequentially.
1985
+ """
1986
+ directive @serial on QUERY
1987
+ `;
1988
+
1989
+ // src/export-directive-envelop-hooks/plugin.ts
1990
+ var import_graphql7 = require("graphql");
1991
+
1992
+ // src/export-directive-envelop-hooks/ExportStore.ts
1621
1993
  var ExportStore = class {
1622
1994
  store = /* @__PURE__ */ new Map();
1623
1995
  pending = /* @__PURE__ */ new Map();
@@ -1636,22 +2008,23 @@ var ExportStore = class {
1636
2008
  }
1637
2009
  /**
1638
2010
  * Accumulate values into an array with deduplication
1639
- * First call initializes an array, subsequent calls add to it
1640
- * Use this when the same export variable is used in multiple array items
2011
+ * Works great with @serial directive to build arrays from sequential field exports
1641
2012
  */
1642
2013
  accumulate(name, value) {
1643
2014
  if (!this.accumulators.has(name)) {
1644
2015
  this.accumulators.set(name, /* @__PURE__ */ new Set());
1645
2016
  }
1646
2017
  const accumulator = this.accumulators.get(name);
1647
- if (Array.isArray(value)) {
1648
- value.forEach((item) => {
1649
- if (item !== null && item !== void 0) {
1650
- accumulator.add(item);
1651
- }
1652
- });
1653
- } else if (value !== null && value !== void 0) {
1654
- accumulator.add(value);
2018
+ if (value !== null && value !== void 0) {
2019
+ if (Array.isArray(value)) {
2020
+ value.forEach((item) => {
2021
+ if (item !== null && item !== void 0) {
2022
+ accumulator.add(item);
2023
+ }
2024
+ });
2025
+ } else {
2026
+ accumulator.add(value);
2027
+ }
1655
2028
  }
1656
2029
  const accumulatedArray = Array.from(accumulator);
1657
2030
  this.store.set(name, accumulatedArray);
@@ -1721,72 +2094,15 @@ var ExportStore = class {
1721
2094
  }
1722
2095
  };
1723
2096
 
1724
- // src/export-tool/middleware.ts
1725
- init_utils();
1726
- function createExportMiddleware() {
1727
- return (next) => {
1728
- return async (source, args, context, info) => {
1729
- if (!context.exportStore) {
1730
- context.exportStore = new ExportStore();
1731
- }
1732
- const exportStore = context.exportStore;
1733
- let resolvedArgs = args;
1734
- if (args && typeof args === "object" && hasExportVariables(args)) {
1735
- try {
1736
- resolvedArgs = await resolveExportVariables(args, exportStore);
1737
- } catch (error) {
1738
- if (error instanceof Error && error.message.includes("Timeout waiting for export variable")) {
1739
- throw new Error(
1740
- `Failed to resolve export variables in ${info.parentType.name}.${info.fieldName}: ${error.message}. Consider using a fallback value or checking if the exported field can return null.`
1741
- );
1742
- }
1743
- throw new Error(
1744
- `Failed to resolve export variables in ${info.parentType.name}.${info.fieldName}: ${error instanceof Error ? error.message : String(error)}`
1745
- );
1746
- }
1747
- }
1748
- const result = await next(source, resolvedArgs, context, info);
1749
- const fieldNode = info.fieldNodes[0];
1750
- if (!fieldNode)
1751
- return result;
1752
- const selfExportName = getExportDirective(fieldNode);
1753
- if (selfExportName && result !== void 0) {
1754
- if (Array.isArray(result)) {
1755
- result.forEach(
1756
- (value) => exportStore.accumulate(selfExportName, value)
1757
- );
1758
- } else {
1759
- exportStore.set(selfExportName, result);
1760
- }
1761
- }
1762
- if (fieldNode.selectionSet && result !== void 0 && result !== null) {
1763
- if (Array.isArray(result)) {
1764
- result.forEach((item) => {
1765
- if (item && typeof item === "object") {
1766
- processExports(item, fieldNode.selectionSet, exportStore, true);
1767
- }
1768
- });
1769
- } else if (typeof result === "object") {
1770
- processExports(result, fieldNode.selectionSet, exportStore, false);
1771
- }
1772
- }
1773
- return result;
1774
- };
1775
- };
1776
- }
1777
-
1778
- // src/export-tool/index.ts
1779
- init_utils();
1780
-
1781
- // src/export-tool/makeScalarAcceptExports.ts
1782
- var import_graphql5 = require("graphql");
2097
+ // src/export-directive-envelop-hooks/utils.ts
2098
+ var import_graphql6 = require("graphql");
1783
2099
  function makeScalarAcceptExports(originalScalar) {
1784
2100
  const config = originalScalar.toConfig();
1785
- return new import_graphql5.GraphQLScalarType({
2101
+ return new import_graphql6.GraphQLScalarType({
1786
2102
  ...config,
1787
2103
  name: config.name,
1788
2104
  // Keep original name to override it in schema
1789
- description: `${config.description} (Wrapped with makeScalarAcceptExports to accept $_ export variables)`,
2105
+ description: config.description + " (Wrapped with makeScalarAcceptExports to accept $_ export variables)",
1790
2106
  serialize: config.serialize,
1791
2107
  parseValue(value) {
1792
2108
  if (typeof value === "string" && (value.startsWith("$_") || value === "")) {
@@ -1798,18 +2114,527 @@ function makeScalarAcceptExports(originalScalar) {
1798
2114
  return value;
1799
2115
  },
1800
2116
  parseLiteral(ast, variables) {
1801
- if (ast.kind === import_graphql5.Kind.STRING) {
2117
+ if (ast.kind === import_graphql6.Kind.STRING) {
1802
2118
  if (ast.value.startsWith("$_") || ast.value === "") {
1803
2119
  return ast.value;
1804
2120
  }
1805
2121
  }
1806
- if (config.parseLiteral) {
2122
+ if (config.parseLiteral && ast) {
1807
2123
  return config.parseLiteral(ast, variables);
1808
2124
  }
1809
2125
  return void 0;
1810
2126
  }
1811
2127
  });
1812
2128
  }
2129
+ function isExportVariable2(value) {
2130
+ if (typeof value !== "string") {
2131
+ return false;
2132
+ }
2133
+ return value.startsWith("$_") && value.length > 2 || value.startsWith("EXPORT_VAR:") && value.length > 11;
2134
+ }
2135
+ function getVariableName2(value) {
2136
+ if (!isExportVariable2(value)) {
2137
+ return null;
2138
+ }
2139
+ if (value.startsWith("$_")) {
2140
+ return value.slice(2);
2141
+ } else if (value.startsWith("EXPORT_VAR:")) {
2142
+ return value.slice(11);
2143
+ }
2144
+ return null;
2145
+ }
2146
+ async function resolveExportVariables2(args, exportStore, timeout = 5e3) {
2147
+ if (isExportVariable2(args)) {
2148
+ const varName = getVariableName2(args);
2149
+ const resolvedValue = await exportStore.waitFor(varName, timeout, false);
2150
+ return resolvedValue;
2151
+ }
2152
+ if (Array.isArray(args)) {
2153
+ const resolved = await Promise.all(
2154
+ args.map(async (item) => {
2155
+ if (isExportVariable2(item)) {
2156
+ const varName = getVariableName2(item);
2157
+ const resolvedValue = await exportStore.waitFor(
2158
+ varName,
2159
+ timeout,
2160
+ false
2161
+ );
2162
+ return Array.isArray(resolvedValue) ? resolvedValue : [resolvedValue];
2163
+ } else if (typeof item === "object" && item !== null) {
2164
+ return await resolveExportVariables2(item, exportStore, timeout);
2165
+ }
2166
+ return item;
2167
+ })
2168
+ );
2169
+ return resolved.flat();
2170
+ }
2171
+ if (typeof args === "object" && args !== null) {
2172
+ const resolved = {};
2173
+ for (const [key, value] of Object.entries(args)) {
2174
+ if (isExportVariable2(value)) {
2175
+ const varName = getVariableName2(value);
2176
+ const resolvedValue = await exportStore.waitFor(
2177
+ varName,
2178
+ timeout,
2179
+ false
2180
+ );
2181
+ resolved[key] = resolvedValue;
2182
+ } else if (typeof value === "object" && value !== null) {
2183
+ resolved[key] = await resolveExportVariables2(
2184
+ value,
2185
+ exportStore,
2186
+ timeout
2187
+ );
2188
+ } else {
2189
+ resolved[key] = value;
2190
+ }
2191
+ }
2192
+ return resolved;
2193
+ }
2194
+ return args;
2195
+ }
2196
+ function getExportDirective2(fieldNode) {
2197
+ if (!fieldNode || !fieldNode.directives) {
2198
+ return null;
2199
+ }
2200
+ const exportDirective = fieldNode.directives.find(
2201
+ (directive) => directive.name.value === "export"
2202
+ );
2203
+ if (!exportDirective) {
2204
+ return null;
2205
+ }
2206
+ const asArg = exportDirective.arguments?.find(
2207
+ (arg) => arg.name.value === "as"
2208
+ );
2209
+ if (!asArg || asArg.value.kind !== "StringValue") {
2210
+ return null;
2211
+ }
2212
+ return asArg.value.value;
2213
+ }
2214
+ function hasExportVariables2(args) {
2215
+ if (isExportVariable2(args)) {
2216
+ return true;
2217
+ }
2218
+ if (Array.isArray(args)) {
2219
+ return args.some((item) => hasExportVariables2(item));
2220
+ }
2221
+ if (typeof args === "object" && args !== null) {
2222
+ for (const value of Object.values(args)) {
2223
+ if (hasExportVariables2(value)) {
2224
+ return true;
2225
+ }
2226
+ }
2227
+ }
2228
+ return false;
2229
+ }
2230
+ function processExports2(result, selectionSet, exportStore, variables, isArrayItem = false) {
2231
+ if (!result || !selectionSet)
2232
+ return;
2233
+ for (const selection of selectionSet.selections) {
2234
+ if (selection.kind !== "Field")
2235
+ continue;
2236
+ const resultKey = selection.alias?.value ?? selection.name.value;
2237
+ if (!(resultKey in result)) {
2238
+ continue;
2239
+ }
2240
+ const value = result[resultKey];
2241
+ const exportName = getExportDirective2(selection);
2242
+ if (exportName) {
2243
+ logExportExecution("Found @export directive: " + exportName, {
2244
+ isArrayItem,
2245
+ value: typeof value
2246
+ });
2247
+ if (isArrayItem) {
2248
+ exportStore.accumulate(exportName, value);
2249
+ } else {
2250
+ exportStore.set(exportName, value);
2251
+ }
2252
+ if (variables && exportName.startsWith("$_")) {
2253
+ const varName = "_" + exportName.slice(2);
2254
+ if (isArrayItem) {
2255
+ if (!variables[varName]) {
2256
+ variables[varName] = [];
2257
+ }
2258
+ if (Array.isArray(variables[varName])) {
2259
+ if (!variables[varName].includes(value)) {
2260
+ variables[varName].push(value);
2261
+ }
2262
+ }
2263
+ } else {
2264
+ variables[varName] = value;
2265
+ }
2266
+ logExportExecution(
2267
+ "Updated GraphQL variable: " + varName,
2268
+ variables[varName]
2269
+ );
2270
+ }
2271
+ }
2272
+ if (selection.selectionSet && value !== null && value !== void 0) {
2273
+ if (Array.isArray(value)) {
2274
+ value.forEach((item) => {
2275
+ if (item && typeof item === "object") {
2276
+ processExports2(
2277
+ item,
2278
+ selection.selectionSet,
2279
+ exportStore,
2280
+ variables,
2281
+ true
2282
+ );
2283
+ }
2284
+ });
2285
+ } else if (typeof value === "object") {
2286
+ processExports2(
2287
+ value,
2288
+ selection.selectionSet,
2289
+ exportStore,
2290
+ variables,
2291
+ isArrayItem
2292
+ );
2293
+ }
2294
+ }
2295
+ }
2296
+ }
2297
+ async function resolveGraphQLVariables2(args, fieldNode, exportStore, timeout = 5e3) {
2298
+ if (!fieldNode.arguments || !args)
2299
+ return;
2300
+ logExportExecution("resolveGraphQLVariables starting", {
2301
+ argsKeys: Object.keys(args)
2302
+ });
2303
+ for (const arg of fieldNode.arguments) {
2304
+ const argName = arg.name.value;
2305
+ if (argName in args) {
2306
+ await traverseASTAndResolve(
2307
+ arg.value,
2308
+ args,
2309
+ argName,
2310
+ exportStore,
2311
+ timeout
2312
+ );
2313
+ } else {
2314
+ logExportExecution("argName not in args", argName);
2315
+ }
2316
+ }
2317
+ }
2318
+ function normalizeFilterOperators(obj) {
2319
+ if (!obj || typeof obj !== "object")
2320
+ return;
2321
+ if (Array.isArray(obj)) {
2322
+ obj.forEach((item) => normalizeFilterOperators(item));
2323
+ return;
2324
+ }
2325
+ for (const key of Object.keys(obj)) {
2326
+ const value = obj[key];
2327
+ if (key === "in" && value !== void 0 && !("inArray" in obj)) {
2328
+ obj.inArray = value;
2329
+ delete obj.in;
2330
+ } else if (value && typeof value === "object") {
2331
+ normalizeFilterOperators(value);
2332
+ }
2333
+ }
2334
+ }
2335
+ async function traverseASTAndResolve(node, parentObj, key, exportStore, timeout) {
2336
+ logExportExecution("traverseASTAndResolve", { kind: node.kind, key });
2337
+ if (node.kind === import_graphql6.Kind.VARIABLE) {
2338
+ const varName = node.name.value;
2339
+ const candidateNames = ["$" + varName, varName];
2340
+ if (varName.startsWith("_")) {
2341
+ candidateNames.push("$" + varName);
2342
+ } else {
2343
+ candidateNames.push("$_" + varName);
2344
+ }
2345
+ const currentValue = parentObj[key];
2346
+ const isDefault = currentValue === void 0 || currentValue === "" || Array.isArray(currentValue) && (currentValue.length === 0 || currentValue.length === 1 && currentValue[0] === "");
2347
+ logExportExecution("Checking variable", {
2348
+ varName,
2349
+ currentValue,
2350
+ isDefault
2351
+ });
2352
+ if (isDefault) {
2353
+ const exportName = "$" + varName;
2354
+ logExportExecution("Waiting for export variable mapping", {
2355
+ varName,
2356
+ exportName
2357
+ });
2358
+ try {
2359
+ const val = await exportStore.waitFor(exportName, timeout, true);
2360
+ if (val !== void 0) {
2361
+ parentObj[key] = val;
2362
+ logExportExecution(
2363
+ "Resolved variable " + varName + " to export " + exportName,
2364
+ val
2365
+ );
2366
+ } else {
2367
+ logExportExecution(
2368
+ "Export variable resolved to undefined (allowed)",
2369
+ exportName
2370
+ );
2371
+ }
2372
+ } catch (e) {
2373
+ logExportExecution(
2374
+ "Timeout waiting for variable " + varName + " as export " + exportName
2375
+ );
2376
+ }
2377
+ }
2378
+ } else if (node.kind === import_graphql6.Kind.OBJECT) {
2379
+ let obj = parentObj[key];
2380
+ if (!obj || typeof obj !== "object") {
2381
+ obj = {};
2382
+ parentObj[key] = obj;
2383
+ }
2384
+ for (const field of node.fields) {
2385
+ const fieldName = field.name.value;
2386
+ await traverseASTAndResolve(
2387
+ field.value,
2388
+ obj,
2389
+ fieldName,
2390
+ exportStore,
2391
+ timeout
2392
+ );
2393
+ }
2394
+ } else if (node.kind === import_graphql6.Kind.LIST) {
2395
+ let list = parentObj[key];
2396
+ if (!Array.isArray(list)) {
2397
+ list = new Array(node.values.length).fill(void 0);
2398
+ parentObj[key] = list;
2399
+ }
2400
+ const len = Math.min(list.length, node.values.length);
2401
+ for (let i = 0; i < len; i++) {
2402
+ await traverseASTAndResolve(
2403
+ node.values[i],
2404
+ list,
2405
+ i,
2406
+ exportStore,
2407
+ timeout
2408
+ );
2409
+ }
2410
+ }
2411
+ }
2412
+ function logExportExecution(message, data) {
2413
+ if (process.env["DEBUG_EXPORT"]) {
2414
+ console.log("[EXPORT-HOOK] " + message, data || "");
2415
+ }
2416
+ }
2417
+
2418
+ // src/export-directive-envelop-hooks/plugin.ts
2419
+ var processedSchemas2 = /* @__PURE__ */ new WeakSet();
2420
+ var useExportDirective = () => {
2421
+ return {
2422
+ onExecute({ args, setExecuteFn }) {
2423
+ if (!args.contextValue) {
2424
+ args.contextValue = {};
2425
+ }
2426
+ const context = args.contextValue;
2427
+ if (!context.exportStore) {
2428
+ context.exportStore = new ExportStore();
2429
+ logExportExecution("Created new ExportStore in context");
2430
+ }
2431
+ const exportStore = context.exportStore;
2432
+ const initialVariables = args.variableValues || {};
2433
+ if (!context._graphqlVariables) {
2434
+ context._graphqlVariables = { ...initialVariables };
2435
+ logExportExecution(
2436
+ "Stored GraphQL variables reference",
2437
+ Object.keys(initialVariables)
2438
+ );
2439
+ }
2440
+ const createWrappedResolver = (originalResolver) => {
2441
+ return async (source, fieldArgs, fieldContext, info) => {
2442
+ const ctx = fieldContext;
2443
+ const store = ctx.exportStore;
2444
+ const isComments = info.fieldName === "comments" || info.fieldName === "commentFindMany";
2445
+ if (isComments) {
2446
+ logExportExecution("DEBUG Resolver Called", {
2447
+ fieldName: info.fieldName,
2448
+ args: JSON.stringify(fieldArgs),
2449
+ variables: JSON.stringify(ctx._graphqlVariables)
2450
+ });
2451
+ }
2452
+ let currentArgs = fieldArgs;
2453
+ if (ctx._graphqlVariables && info.parentType instanceof import_graphql7.GraphQLObjectType) {
2454
+ const fieldNode2 = info.fieldNodes[0];
2455
+ if (!fieldNode2) {
2456
+ if (isComments) {
2457
+ logExportExecution("DEBUG fieldNode NOT FOUND");
2458
+ }
2459
+ } else {
2460
+ const fieldName = fieldNode2.name.value;
2461
+ const fieldDef = info.parentType.getFields()[fieldName];
2462
+ if (isComments && !fieldDef) {
2463
+ logExportExecution("DEBUG fieldDef NOT FOUND");
2464
+ }
2465
+ if (fieldDef) {
2466
+ try {
2467
+ if (isComments) {
2468
+ logExportExecution("DEBUG calling getArgumentValues", {
2469
+ fieldNodeName: fieldNode2.name.value,
2470
+ fieldDefName: fieldDef.name,
2471
+ variablesKeys: Object.keys(
2472
+ ctx._graphqlVariables || {}
2473
+ )
2474
+ });
2475
+ }
2476
+ const freshArgs = (0, import_graphql7.getArgumentValues)(
2477
+ fieldDef,
2478
+ fieldNode2,
2479
+ ctx._graphqlVariables
2480
+ );
2481
+ if (isComments) {
2482
+ logExportExecution("DEBUG getArgumentValues result", {
2483
+ freshArgsKeys: Object.keys(freshArgs || {}),
2484
+ freshArgs: JSON.stringify(freshArgs)
2485
+ });
2486
+ }
2487
+ if (freshArgs) {
2488
+ currentArgs = freshArgs;
2489
+ }
2490
+ } catch (e) {
2491
+ logExportExecution(
2492
+ "Failed to re-resolve args for " + info.fieldName,
2493
+ e
2494
+ );
2495
+ }
2496
+ }
2497
+ }
2498
+ }
2499
+ let resolvedArgs = currentArgs;
2500
+ const fieldNode = info.fieldNodes[0];
2501
+ if (currentArgs && typeof currentArgs === "object") {
2502
+ if (fieldNode) {
2503
+ try {
2504
+ await resolveGraphQLVariables2(
2505
+ currentArgs,
2506
+ fieldNode,
2507
+ store,
2508
+ 1e4
2509
+ );
2510
+ } catch (error) {
2511
+ logExportExecution("GraphQL variable resolution failed", error);
2512
+ }
2513
+ }
2514
+ normalizeFilterOperators(currentArgs);
2515
+ if (hasExportVariables2(currentArgs)) {
2516
+ try {
2517
+ resolvedArgs = await resolveExportVariables2(
2518
+ currentArgs,
2519
+ store,
2520
+ 1e4
2521
+ );
2522
+ } catch (error) {
2523
+ throw new Error(
2524
+ "Export variable resolution failed in " + info.parentType.name + "." + info.fieldName + ": " + (error instanceof Error ? error.message : String(error))
2525
+ );
2526
+ }
2527
+ }
2528
+ }
2529
+ let result;
2530
+ if (originalResolver) {
2531
+ result = await originalResolver(
2532
+ source,
2533
+ resolvedArgs,
2534
+ fieldContext,
2535
+ info
2536
+ );
2537
+ } else {
2538
+ const fieldName = info.fieldName;
2539
+ result = source?.[fieldName];
2540
+ }
2541
+ if (fieldNode) {
2542
+ const selfExportName = getExportDirective2(fieldNode);
2543
+ if (selfExportName && result !== void 0 && result !== null) {
2544
+ if (!fieldNode.selectionSet) {
2545
+ logExportExecution(
2546
+ "Setting field-level export: " + selfExportName,
2547
+ { value: result }
2548
+ );
2549
+ store.set(selfExportName, result);
2550
+ if (selfExportName.startsWith("$_")) {
2551
+ const varName = "_" + selfExportName.slice(2);
2552
+ if (ctx._graphqlVariables) {
2553
+ const currentVal = ctx._graphqlVariables[varName];
2554
+ if (Array.isArray(currentVal)) {
2555
+ if (!currentVal.includes(result) && result !== "") {
2556
+ currentVal.push(result);
2557
+ }
2558
+ } else {
2559
+ ctx._graphqlVariables[varName] = result;
2560
+ }
2561
+ logExportExecution(
2562
+ "Updated GraphQL variable: " + varName,
2563
+ ctx._graphqlVariables[varName]
2564
+ );
2565
+ }
2566
+ }
2567
+ }
2568
+ }
2569
+ if (fieldNode && fieldNode.selectionSet && result !== void 0 && result !== null) {
2570
+ if (Array.isArray(result)) {
2571
+ result.forEach((item) => {
2572
+ if (item && typeof item === "object") {
2573
+ processExports2(
2574
+ item,
2575
+ fieldNode.selectionSet,
2576
+ store,
2577
+ ctx._graphqlVariables,
2578
+ true
2579
+ );
2580
+ }
2581
+ });
2582
+ } else if (typeof result === "object") {
2583
+ processExports2(
2584
+ result,
2585
+ fieldNode.selectionSet,
2586
+ store,
2587
+ ctx._graphqlVariables,
2588
+ false
2589
+ );
2590
+ }
2591
+ }
2592
+ }
2593
+ return result;
2594
+ };
2595
+ };
2596
+ if (args.schema && !processedSchemas2.has(args.schema)) {
2597
+ processedSchemas2.add(args.schema);
2598
+ logExportExecution("Wrapping schema resolvers");
2599
+ const typeMap = args.schema.getTypeMap();
2600
+ for (const typeName in typeMap) {
2601
+ const type = typeMap[typeName];
2602
+ if (type instanceof import_graphql7.GraphQLObjectType && !typeName.startsWith("__")) {
2603
+ const fields = type.getFields();
2604
+ for (const fieldName in fields) {
2605
+ const field = fields[fieldName];
2606
+ if (!field) {
2607
+ continue;
2608
+ }
2609
+ if (field.resolve) {
2610
+ field.resolve = createWrappedResolver(field.resolve);
2611
+ }
2612
+ }
2613
+ }
2614
+ }
2615
+ }
2616
+ args.fieldResolver = createWrappedResolver(args.fieldResolver);
2617
+ return {
2618
+ onExecuteDone() {
2619
+ logExportExecution("Export execution completed", {
2620
+ exports: exportStore.getAll(),
2621
+ variables: context._graphqlVariables || {}
2622
+ });
2623
+ }
2624
+ };
2625
+ }
2626
+ };
2627
+ };
2628
+
2629
+ // src/export-directive-envelop-hooks/directive-definitions.ts
2630
+ var exportDirectiveTypeDefs = `
2631
+ """
2632
+ Exports a field value for use by other fields in the same query.
2633
+ The exported value can be referenced using the pattern $_variableName or EXPORT_VAR:variableName.
2634
+ Supports accumulation when used on array items.
2635
+ """
2636
+ directive @export(as: String!) on FIELD
2637
+ `;
1813
2638
 
1814
2639
  // src/helpers.ts
1815
2640
  var import_drizzle_orm9 = require("drizzle-orm");
@@ -1840,16 +2665,19 @@ function setCustomGraphQLTypes(table, columnTypes) {
1840
2665
  }
1841
2666
  // Annotate the CommonJS export names for ESM import in node:
1842
2667
  0 && (module.exports = {
2668
+ ExportStore,
1843
2669
  buildSchemaSDLWithDataLoader,
1844
2670
  cleanupDataLoaderContext,
1845
2671
  createDataLoaderContext,
1846
- createExportMiddleware,
1847
2672
  exportDirectiveTypeDefs,
1848
2673
  makeScalarAcceptExports,
2674
+ serialDirectiveTypeDefs,
1849
2675
  setCustomGraphQL,
1850
2676
  setCustomGraphQLTypes,
1851
2677
  useDataLoaderCleanup,
1852
2678
  useDataLoaderCleanupOnly,
1853
- useDataLoaderContext
2679
+ useDataLoaderContext,
2680
+ useExportDirective,
2681
+ useSerialDirective
1854
2682
  });
1855
2683
  //# sourceMappingURL=index.cjs.map