drizzle-graphql-plus 0.8.39 → 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
@@ -1932,7 +1932,12 @@ var useSerialDirective = () => {
1932
1932
  });
1933
1933
  let result;
1934
1934
  if (originalResolver) {
1935
- result = await originalResolver(source, fieldArgs, fieldContext, info);
1935
+ result = await originalResolver(
1936
+ source,
1937
+ fieldArgs,
1938
+ fieldContext,
1939
+ info
1940
+ );
1936
1941
  } else {
1937
1942
  const fieldName = info.fieldName;
1938
1943
  result = source?.[fieldName];
@@ -2438,6 +2443,17 @@ var useExportDirective = () => {
2438
2443
  );
2439
2444
  }
2440
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
+ };
2441
2457
  return async (source, fieldArgs, fieldContext, info) => {
2442
2458
  const ctx = fieldContext;
2443
2459
  const store = ctx.exportStore;
@@ -2449,55 +2465,9 @@ var useExportDirective = () => {
2449
2465
  variables: JSON.stringify(ctx._graphqlVariables)
2450
2466
  });
2451
2467
  }
2468
+ const fieldNode = info.fieldNodes[0];
2452
2469
  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
2470
  let resolvedArgs = currentArgs;
2500
- const fieldNode = info.fieldNodes[0];
2501
2471
  if (currentArgs && typeof currentArgs === "object") {
2502
2472
  if (fieldNode) {
2503
2473
  try {
@@ -2526,6 +2496,47 @@ var useExportDirective = () => {
2526
2496
  }
2527
2497
  }
2528
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
+ }
2529
2540
  let result;
2530
2541
  if (originalResolver) {
2531
2542
  result = await originalResolver(