graphql-modules 2.4.1-alpha-20250219023342-88dc61eee3a181fbaa65c36e13358cd4524c54fb → 2.4.1

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.
@@ -3,7 +3,10 @@ import { ResolvedProvider } from '../di/resolution';
3
3
  import type { InternalAppContext, ModulesMap } from './application';
4
4
  export type ExecutionContextBuilder<TContext extends {
5
5
  [key: string]: any;
6
- } = {}> = (context: TContext) => {
6
+ } = {}> = (context: TContext) => ExecutionContextEnv & {
7
+ runWithContext<TReturn = any>(cb: (env: ExecutionContextEnv) => TReturn): TReturn;
8
+ };
9
+ export type ExecutionContextEnv = {
7
10
  context: InternalAppContext;
8
11
  ɵdestroy(): void;
9
12
  ɵinjector: Injector;
@@ -3,6 +3,6 @@ import { ExecutionContextBuilder } from './context';
3
3
  export declare function executionCreator({ contextBuilder, }: {
4
4
  contextBuilder: ExecutionContextBuilder;
5
5
  }): (options?: {
6
- execute?: typeof execute;
7
- controller?: import("./types").OperationController;
8
- }) => typeof execute;
6
+ execute?: typeof execute | undefined;
7
+ controller?: import("./types").OperationController | undefined;
8
+ } | undefined) => typeof execute;
@@ -3,6 +3,6 @@ import { ExecutionContextBuilder } from './context';
3
3
  export declare function subscriptionCreator({ contextBuilder, }: {
4
4
  contextBuilder: ExecutionContextBuilder;
5
5
  }): (options?: {
6
- subscribe?: typeof subscribe;
7
- controller?: import("./types").OperationController;
8
- }) => typeof subscribe;
6
+ subscribe?: typeof subscribe | undefined;
7
+ controller?: import("./types").OperationController | undefined;
8
+ } | undefined) => typeof subscribe;
@@ -0,0 +1,7 @@
1
+ // noop
2
+ // TODO: typecheck
3
+
4
+ export default {
5
+ getAsyncContext: () => undefined,
6
+ runWithAsyncContext: (_asyncContext, callback, ...args) => callback(...args),
7
+ };
@@ -0,0 +1,14 @@
1
+ // use async hooks
2
+ // TODO: typecheck
3
+
4
+ const hooks = require('async_hooks');
5
+
6
+ const alc = new hooks.AsyncLocalStorage();
7
+
8
+ // we dont use named exports (exports.getAsyncContext) because node with typescript is weird
9
+
10
+ module.exports = {
11
+ getAsyncContext: () => alc.getStore(),
12
+ runWithAsyncContext: (asyncContext, callback, ...args) =>
13
+ alc.run(asyncContext, callback, ...args),
14
+ };
package/index.js CHANGED
@@ -2,8 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
+
5
7
  const schema = require('@graphql-tools/schema');
6
8
  const graphql = require('graphql');
9
+ const async_context = _interopDefault(require('#async-context'));
7
10
  const wrap = require('@graphql-tools/wrap');
8
11
  const ramda = require('ramda');
9
12
 
@@ -732,9 +735,9 @@ function tapAsyncIterator(iterable, doneCallback) {
732
735
  throw error;
733
736
  }
734
737
  },
735
- async return(value) {
738
+ async return() {
736
739
  try {
737
- const result = await iterator.return(value);
740
+ const result = await iterator.return();
738
741
  return mapResult(result);
739
742
  }
740
743
  catch (error) {
@@ -742,7 +745,7 @@ function tapAsyncIterator(iterable, doneCallback) {
742
745
  throw error;
743
746
  }
744
747
  },
745
- throw(error) {
748
+ async throw(error) {
746
749
  doneCallback();
747
750
  return iterator.throw(error);
748
751
  },
@@ -882,11 +885,14 @@ function createContextBuilder({ appInjector, modulesMap, appLevelOperationProvid
882
885
  },
883
886
  });
884
887
  appInjector.setExecutionContextGetter(function executionContextGetter() {
885
- return appContext;
888
+ var _a;
889
+ return (((_a = async_context.getAsyncContext()) === null || _a === void 0 ? void 0 : _a.getApplicationContext()) || appContext);
886
890
  });
887
891
  function createModuleExecutionContextGetter(moduleId) {
888
892
  return function moduleExecutionContextGetter() {
889
- return getModuleContext(moduleId, context);
893
+ var _a;
894
+ return (((_a = async_context.getAsyncContext()) === null || _a === void 0 ? void 0 : _a.getModuleContext(moduleId)) ||
895
+ getModuleContext(moduleId, context));
890
896
  };
891
897
  }
892
898
  modulesMap.forEach((mod, moduleId) => {
@@ -956,7 +962,7 @@ function createContextBuilder({ appInjector, modulesMap, appLevelOperationProvid
956
962
  return getModuleContext(moduleId, sharedContext).injector;
957
963
  },
958
964
  });
959
- return {
965
+ const env = {
960
966
  ɵdestroy: once(() => {
961
967
  providersToDestroy.forEach(([injector, keyId]) => {
962
968
  // If provider was instantiated
@@ -970,6 +976,19 @@ function createContextBuilder({ appInjector, modulesMap, appLevelOperationProvid
970
976
  ɵinjector: operationAppInjector,
971
977
  context: sharedContext,
972
978
  };
979
+ return {
980
+ ...env,
981
+ runWithContext(cb) {
982
+ return async_context.runWithAsyncContext({
983
+ getApplicationContext() {
984
+ return appContext;
985
+ },
986
+ getModuleContext(moduleId) {
987
+ return getModuleContext(moduleId, context);
988
+ },
989
+ }, cb, env);
990
+ },
991
+ };
973
992
  };
974
993
  return contextBuilder;
975
994
  }
@@ -979,31 +998,34 @@ function executionCreator({ contextBuilder, }) {
979
998
  // Custom or original execute function
980
999
  const executeFn = (options === null || options === void 0 ? void 0 : options.execute) || graphql.execute;
981
1000
  return (argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) => {
982
- var _a;
983
- // Create an execution context
984
- const { context, ɵdestroy: destroy } = (_a = options === null || options === void 0 ? void 0 : options.controller) !== null && _a !== void 0 ? _a : contextBuilder(isNotSchema(argsOrSchema)
1001
+ function perform({ context, ɵdestroy: destroy, }) {
1002
+ const executionArgs = isNotSchema(argsOrSchema)
1003
+ ? {
1004
+ ...argsOrSchema,
1005
+ contextValue: context,
1006
+ }
1007
+ : {
1008
+ schema: argsOrSchema,
1009
+ document: document,
1010
+ rootValue,
1011
+ contextValue: context,
1012
+ variableValues,
1013
+ operationName,
1014
+ fieldResolver,
1015
+ typeResolver,
1016
+ };
1017
+ // It's important to wrap the executeFn within a promise
1018
+ // so we can easily control the end of execution (with finally)
1019
+ return Promise.resolve()
1020
+ .then(() => executeFn(executionArgs))
1021
+ .finally(destroy);
1022
+ }
1023
+ if (options === null || options === void 0 ? void 0 : options.controller) {
1024
+ return perform(options.controller);
1025
+ }
1026
+ return contextBuilder(isNotSchema(argsOrSchema)
985
1027
  ? argsOrSchema.contextValue
986
- : contextValue);
987
- const executionArgs = isNotSchema(argsOrSchema)
988
- ? {
989
- ...argsOrSchema,
990
- contextValue: context,
991
- }
992
- : {
993
- schema: argsOrSchema,
994
- document: document,
995
- rootValue,
996
- contextValue: context,
997
- variableValues,
998
- operationName,
999
- fieldResolver,
1000
- typeResolver,
1001
- };
1002
- // It's important to wrap the executeFn within a promise
1003
- // so we can easily control the end of execution (with finally)
1004
- return Promise.resolve()
1005
- .then(() => executeFn(executionArgs))
1006
- .finally(destroy);
1028
+ : contextValue).runWithContext(perform);
1007
1029
  };
1008
1030
  };
1009
1031
  return createExecution;
@@ -1014,43 +1036,46 @@ function subscriptionCreator({ contextBuilder, }) {
1014
1036
  // Custom or original subscribe function
1015
1037
  const subscribeFn = (options === null || options === void 0 ? void 0 : options.subscribe) || graphql.subscribe;
1016
1038
  return (argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver) => {
1017
- var _a;
1018
- // Create an subscription context
1019
- const { context, ɵdestroy: destroy } = (_a = options === null || options === void 0 ? void 0 : options.controller) !== null && _a !== void 0 ? _a : contextBuilder(isNotSchema(argsOrSchema)
1039
+ function perform({ context, ɵdestroy: destroy, }) {
1040
+ const subscriptionArgs = isNotSchema(argsOrSchema)
1041
+ ? {
1042
+ ...argsOrSchema,
1043
+ contextValue: context,
1044
+ }
1045
+ : {
1046
+ schema: argsOrSchema,
1047
+ document: document,
1048
+ rootValue,
1049
+ contextValue: context,
1050
+ variableValues,
1051
+ operationName,
1052
+ fieldResolver,
1053
+ subscribeFieldResolver,
1054
+ };
1055
+ let isIterable = false;
1056
+ // It's important to wrap the subscribeFn within a promise
1057
+ // so we can easily control the end of subscription (with finally)
1058
+ return Promise.resolve()
1059
+ .then(() => subscribeFn(subscriptionArgs))
1060
+ .then((sub) => {
1061
+ if (isAsyncIterable(sub)) {
1062
+ isIterable = true;
1063
+ return tapAsyncIterator(sub, destroy);
1064
+ }
1065
+ return sub;
1066
+ })
1067
+ .finally(() => {
1068
+ if (!isIterable) {
1069
+ destroy();
1070
+ }
1071
+ });
1072
+ }
1073
+ if (options === null || options === void 0 ? void 0 : options.controller) {
1074
+ return perform(options.controller);
1075
+ }
1076
+ return contextBuilder(isNotSchema(argsOrSchema)
1020
1077
  ? argsOrSchema.contextValue
1021
- : contextValue);
1022
- const subscriptionArgs = isNotSchema(argsOrSchema)
1023
- ? {
1024
- ...argsOrSchema,
1025
- contextValue: context,
1026
- }
1027
- : {
1028
- schema: argsOrSchema,
1029
- document: document,
1030
- rootValue,
1031
- contextValue: context,
1032
- variableValues,
1033
- operationName,
1034
- fieldResolver,
1035
- subscribeFieldResolver,
1036
- };
1037
- let isIterable = false;
1038
- // It's important to wrap the subscribeFn within a promise
1039
- // so we can easily control the end of subscription (with finally)
1040
- return Promise.resolve()
1041
- .then(() => subscribeFn(subscriptionArgs))
1042
- .then((sub) => {
1043
- if (isAsyncIterable(sub)) {
1044
- isIterable = true;
1045
- return tapAsyncIterator(sub, destroy);
1046
- }
1047
- return sub;
1048
- })
1049
- .finally(() => {
1050
- if (!isIterable) {
1051
- destroy();
1052
- }
1053
- });
1078
+ : contextValue).runWithContext(perform);
1054
1079
  };
1055
1080
  };
1056
1081
  return createSubscription;
@@ -1075,10 +1100,9 @@ function apolloSchemaCreator({ createSubscription, contextBuilder, schema, }) {
1075
1100
  const createApolloSchema = () => {
1076
1101
  const sessions = {};
1077
1102
  const subscription = createSubscription();
1078
- function getSession(ctx) {
1103
+ function getSession(ctx, { context, ɵdestroy: destroy }) {
1079
1104
  if (!ctx[CONTEXT_ID]) {
1080
1105
  ctx[CONTEXT_ID] = uniqueId((id) => !sessions[id]);
1081
- const { context, ɵdestroy: destroy } = contextBuilder(ctx);
1082
1106
  sessions[ctx[CONTEXT_ID]] = {
1083
1107
  count: 0,
1084
1108
  session: {
@@ -1110,20 +1134,22 @@ function apolloSchemaCreator({ createSubscription, contextBuilder, schema, }) {
1110
1134
  operationName: input.operationName,
1111
1135
  });
1112
1136
  }
1113
- // Create an execution context
1114
- const { context, destroy } = getSession(input.context);
1115
- // It's important to wrap the executeFn within a promise
1116
- // so we can easily control the end of execution (with finally)
1117
- return Promise.resolve()
1118
- .then(() => graphql.execute({
1119
- schema,
1120
- document: input.document,
1121
- contextValue: context,
1122
- variableValues: input.variables,
1123
- rootValue: input.rootValue,
1124
- operationName: input.operationName,
1125
- }))
1126
- .finally(destroy);
1137
+ // Create an execution context and run within it
1138
+ return contextBuilder(input.context).runWithContext((env) => {
1139
+ const { context, destroy } = getSession(input.context, env);
1140
+ // It's important to wrap the executeFn within a promise
1141
+ // so we can easily control the end of execution (with finally)
1142
+ return Promise.resolve()
1143
+ .then(() => graphql.execute({
1144
+ schema,
1145
+ document: input.document,
1146
+ contextValue: context,
1147
+ variableValues: input.variables,
1148
+ rootValue: input.rootValue,
1149
+ operationName: input.operationName,
1150
+ }))
1151
+ .finally(destroy);
1152
+ });
1127
1153
  },
1128
1154
  });
1129
1155
  };
package/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { makeExecutableSchema } from '@graphql-tools/schema';
2
2
  import { GraphQLSchema, execute as execute$1, subscribe, visit, Kind, GraphQLScalarType, concatAST, defaultFieldResolver, parse } from 'graphql';
3
+ import async_context from '#async-context';
3
4
  import { wrapSchema } from '@graphql-tools/wrap';
4
5
  import { mergeDeepWith } from 'ramda';
5
6
 
@@ -729,9 +730,9 @@ function tapAsyncIterator(iterable, doneCallback) {
729
730
  throw error;
730
731
  }
731
732
  },
732
- async return(value) {
733
+ async return() {
733
734
  try {
734
- const result = await iterator.return(value);
735
+ const result = await iterator.return();
735
736
  return mapResult(result);
736
737
  }
737
738
  catch (error) {
@@ -739,7 +740,7 @@ function tapAsyncIterator(iterable, doneCallback) {
739
740
  throw error;
740
741
  }
741
742
  },
742
- throw(error) {
743
+ async throw(error) {
743
744
  doneCallback();
744
745
  return iterator.throw(error);
745
746
  },
@@ -879,11 +880,14 @@ function createContextBuilder({ appInjector, modulesMap, appLevelOperationProvid
879
880
  },
880
881
  });
881
882
  appInjector.setExecutionContextGetter(function executionContextGetter() {
882
- return appContext;
883
+ var _a;
884
+ return (((_a = async_context.getAsyncContext()) === null || _a === void 0 ? void 0 : _a.getApplicationContext()) || appContext);
883
885
  });
884
886
  function createModuleExecutionContextGetter(moduleId) {
885
887
  return function moduleExecutionContextGetter() {
886
- return getModuleContext(moduleId, context);
888
+ var _a;
889
+ return (((_a = async_context.getAsyncContext()) === null || _a === void 0 ? void 0 : _a.getModuleContext(moduleId)) ||
890
+ getModuleContext(moduleId, context));
887
891
  };
888
892
  }
889
893
  modulesMap.forEach((mod, moduleId) => {
@@ -953,7 +957,7 @@ function createContextBuilder({ appInjector, modulesMap, appLevelOperationProvid
953
957
  return getModuleContext(moduleId, sharedContext).injector;
954
958
  },
955
959
  });
956
- return {
960
+ const env = {
957
961
  ɵdestroy: once(() => {
958
962
  providersToDestroy.forEach(([injector, keyId]) => {
959
963
  // If provider was instantiated
@@ -967,6 +971,19 @@ function createContextBuilder({ appInjector, modulesMap, appLevelOperationProvid
967
971
  ɵinjector: operationAppInjector,
968
972
  context: sharedContext,
969
973
  };
974
+ return {
975
+ ...env,
976
+ runWithContext(cb) {
977
+ return async_context.runWithAsyncContext({
978
+ getApplicationContext() {
979
+ return appContext;
980
+ },
981
+ getModuleContext(moduleId) {
982
+ return getModuleContext(moduleId, context);
983
+ },
984
+ }, cb, env);
985
+ },
986
+ };
970
987
  };
971
988
  return contextBuilder;
972
989
  }
@@ -976,31 +993,34 @@ function executionCreator({ contextBuilder, }) {
976
993
  // Custom or original execute function
977
994
  const executeFn = (options === null || options === void 0 ? void 0 : options.execute) || execute$1;
978
995
  return (argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) => {
979
- var _a;
980
- // Create an execution context
981
- const { context, ɵdestroy: destroy } = (_a = options === null || options === void 0 ? void 0 : options.controller) !== null && _a !== void 0 ? _a : contextBuilder(isNotSchema(argsOrSchema)
996
+ function perform({ context, ɵdestroy: destroy, }) {
997
+ const executionArgs = isNotSchema(argsOrSchema)
998
+ ? {
999
+ ...argsOrSchema,
1000
+ contextValue: context,
1001
+ }
1002
+ : {
1003
+ schema: argsOrSchema,
1004
+ document: document,
1005
+ rootValue,
1006
+ contextValue: context,
1007
+ variableValues,
1008
+ operationName,
1009
+ fieldResolver,
1010
+ typeResolver,
1011
+ };
1012
+ // It's important to wrap the executeFn within a promise
1013
+ // so we can easily control the end of execution (with finally)
1014
+ return Promise.resolve()
1015
+ .then(() => executeFn(executionArgs))
1016
+ .finally(destroy);
1017
+ }
1018
+ if (options === null || options === void 0 ? void 0 : options.controller) {
1019
+ return perform(options.controller);
1020
+ }
1021
+ return contextBuilder(isNotSchema(argsOrSchema)
982
1022
  ? argsOrSchema.contextValue
983
- : contextValue);
984
- const executionArgs = isNotSchema(argsOrSchema)
985
- ? {
986
- ...argsOrSchema,
987
- contextValue: context,
988
- }
989
- : {
990
- schema: argsOrSchema,
991
- document: document,
992
- rootValue,
993
- contextValue: context,
994
- variableValues,
995
- operationName,
996
- fieldResolver,
997
- typeResolver,
998
- };
999
- // It's important to wrap the executeFn within a promise
1000
- // so we can easily control the end of execution (with finally)
1001
- return Promise.resolve()
1002
- .then(() => executeFn(executionArgs))
1003
- .finally(destroy);
1023
+ : contextValue).runWithContext(perform);
1004
1024
  };
1005
1025
  };
1006
1026
  return createExecution;
@@ -1011,43 +1031,46 @@ function subscriptionCreator({ contextBuilder, }) {
1011
1031
  // Custom or original subscribe function
1012
1032
  const subscribeFn = (options === null || options === void 0 ? void 0 : options.subscribe) || subscribe;
1013
1033
  return (argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver) => {
1014
- var _a;
1015
- // Create an subscription context
1016
- const { context, ɵdestroy: destroy } = (_a = options === null || options === void 0 ? void 0 : options.controller) !== null && _a !== void 0 ? _a : contextBuilder(isNotSchema(argsOrSchema)
1034
+ function perform({ context, ɵdestroy: destroy, }) {
1035
+ const subscriptionArgs = isNotSchema(argsOrSchema)
1036
+ ? {
1037
+ ...argsOrSchema,
1038
+ contextValue: context,
1039
+ }
1040
+ : {
1041
+ schema: argsOrSchema,
1042
+ document: document,
1043
+ rootValue,
1044
+ contextValue: context,
1045
+ variableValues,
1046
+ operationName,
1047
+ fieldResolver,
1048
+ subscribeFieldResolver,
1049
+ };
1050
+ let isIterable = false;
1051
+ // It's important to wrap the subscribeFn within a promise
1052
+ // so we can easily control the end of subscription (with finally)
1053
+ return Promise.resolve()
1054
+ .then(() => subscribeFn(subscriptionArgs))
1055
+ .then((sub) => {
1056
+ if (isAsyncIterable(sub)) {
1057
+ isIterable = true;
1058
+ return tapAsyncIterator(sub, destroy);
1059
+ }
1060
+ return sub;
1061
+ })
1062
+ .finally(() => {
1063
+ if (!isIterable) {
1064
+ destroy();
1065
+ }
1066
+ });
1067
+ }
1068
+ if (options === null || options === void 0 ? void 0 : options.controller) {
1069
+ return perform(options.controller);
1070
+ }
1071
+ return contextBuilder(isNotSchema(argsOrSchema)
1017
1072
  ? argsOrSchema.contextValue
1018
- : contextValue);
1019
- const subscriptionArgs = isNotSchema(argsOrSchema)
1020
- ? {
1021
- ...argsOrSchema,
1022
- contextValue: context,
1023
- }
1024
- : {
1025
- schema: argsOrSchema,
1026
- document: document,
1027
- rootValue,
1028
- contextValue: context,
1029
- variableValues,
1030
- operationName,
1031
- fieldResolver,
1032
- subscribeFieldResolver,
1033
- };
1034
- let isIterable = false;
1035
- // It's important to wrap the subscribeFn within a promise
1036
- // so we can easily control the end of subscription (with finally)
1037
- return Promise.resolve()
1038
- .then(() => subscribeFn(subscriptionArgs))
1039
- .then((sub) => {
1040
- if (isAsyncIterable(sub)) {
1041
- isIterable = true;
1042
- return tapAsyncIterator(sub, destroy);
1043
- }
1044
- return sub;
1045
- })
1046
- .finally(() => {
1047
- if (!isIterable) {
1048
- destroy();
1049
- }
1050
- });
1073
+ : contextValue).runWithContext(perform);
1051
1074
  };
1052
1075
  };
1053
1076
  return createSubscription;
@@ -1072,10 +1095,9 @@ function apolloSchemaCreator({ createSubscription, contextBuilder, schema, }) {
1072
1095
  const createApolloSchema = () => {
1073
1096
  const sessions = {};
1074
1097
  const subscription = createSubscription();
1075
- function getSession(ctx) {
1098
+ function getSession(ctx, { context, ɵdestroy: destroy }) {
1076
1099
  if (!ctx[CONTEXT_ID]) {
1077
1100
  ctx[CONTEXT_ID] = uniqueId((id) => !sessions[id]);
1078
- const { context, ɵdestroy: destroy } = contextBuilder(ctx);
1079
1101
  sessions[ctx[CONTEXT_ID]] = {
1080
1102
  count: 0,
1081
1103
  session: {
@@ -1107,20 +1129,22 @@ function apolloSchemaCreator({ createSubscription, contextBuilder, schema, }) {
1107
1129
  operationName: input.operationName,
1108
1130
  });
1109
1131
  }
1110
- // Create an execution context
1111
- const { context, destroy } = getSession(input.context);
1112
- // It's important to wrap the executeFn within a promise
1113
- // so we can easily control the end of execution (with finally)
1114
- return Promise.resolve()
1115
- .then(() => execute$1({
1116
- schema,
1117
- document: input.document,
1118
- contextValue: context,
1119
- variableValues: input.variables,
1120
- rootValue: input.rootValue,
1121
- operationName: input.operationName,
1122
- }))
1123
- .finally(destroy);
1132
+ // Create an execution context and run within it
1133
+ return contextBuilder(input.context).runWithContext((env) => {
1134
+ const { context, destroy } = getSession(input.context, env);
1135
+ // It's important to wrap the executeFn within a promise
1136
+ // so we can easily control the end of execution (with finally)
1137
+ return Promise.resolve()
1138
+ .then(() => execute$1({
1139
+ schema,
1140
+ document: input.document,
1141
+ contextValue: context,
1142
+ variableValues: input.variables,
1143
+ rootValue: input.rootValue,
1144
+ operationName: input.operationName,
1145
+ }))
1146
+ .finally(destroy);
1147
+ });
1124
1148
  },
1125
1149
  });
1126
1150
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphql-modules",
3
- "version": "2.4.1-alpha-20250219023342-88dc61eee3a181fbaa65c36e13358cd4524c54fb",
3
+ "version": "2.4.1",
4
4
  "description": "Create reusable, maintainable, testable and extendable GraphQL modules",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
@@ -10,7 +10,7 @@
10
10
  "@graphql-tools/schema": "^10.0.0",
11
11
  "@graphql-tools/wrap": "^10.0.0",
12
12
  "@graphql-typed-document-node/core": "^3.1.0",
13
- "ramda": "^0.30.0"
13
+ "ramda": "^0.29.0"
14
14
  },
15
15
  "keywords": [
16
16
  "graphql",
@@ -37,5 +37,11 @@
37
37
  "import": "./*.mjs"
38
38
  },
39
39
  "./package.json": "./package.json"
40
+ },
41
+ "imports": {
42
+ "#async-context": {
43
+ "node": "./async-context.node.cjs",
44
+ "default": "./async-context.browser.mjs"
45
+ }
40
46
  }
41
47
  }
@@ -16,6 +16,6 @@ export type MiddlewareMap = {
16
16
  [field: string]: Middleware[];
17
17
  };
18
18
  };
19
- export declare function createMiddleware(path: string[], middlewareMap?: MiddlewareMap): (context: MiddlewareContext, next: Next) => Promise<any>;
19
+ export declare function createMiddleware(path: string[], middlewareMap?: MiddlewareMap): (context: MiddlewareContext, next: Next<any>) => Promise<any>;
20
20
  export declare function mergeMiddlewareMaps(app: MiddlewareMap, mod: MiddlewareMap): MiddlewareMap;
21
21
  export declare function validateMiddlewareMap(middlewareMap: MiddlewareMap, metadata: ModuleMetadata): void;
package/shared/utils.d.ts CHANGED
@@ -4,7 +4,7 @@ export declare function isNil<T>(val: T | null | undefined): val is null | undef
4
4
  export declare function isObject(val: any): boolean;
5
5
  export declare function isPrimitive(val: any): val is number | string | boolean | symbol | bigint;
6
6
  export declare function isAsyncIterable(obj: any): obj is AsyncIterableIterator<any>;
7
- export declare function tapAsyncIterator<T, TAsyncIterableIterator extends AsyncIterableIterator<T>>(iterable: TAsyncIterableIterator, doneCallback: () => void): TAsyncIterableIterator;
7
+ export declare function tapAsyncIterator<T>(iterable: AsyncIterable<T>, doneCallback: () => void): AsyncGenerator<T>;
8
8
  export declare function once(cb: () => void): () => void;
9
9
  export declare function share<T, A>(factory: (arg?: A) => T): (arg?: A) => T;
10
10
  export declare function uniqueId(isNotUsed: (id: string) => boolean): string;