graphql-modules 2.4.1-alpha-20241224125233-8750a83885a9c3564903d48a639541391c8e9a6d → 2.4.1-alpha-20250121000023-bfc739c20cae990e57c710f62c520fe7ac7246a2

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,10 +3,7 @@ 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) => ExecutionContextEnv & {
7
- runWithContext<TReturn = any>(cb: (env: ExecutionContextEnv) => TReturn): TReturn;
8
- };
9
- export type ExecutionContextEnv = {
6
+ } = {}> = (context: TContext) => {
10
7
  context: InternalAppContext;
11
8
  ɵdestroy(): void;
12
9
  ɵ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 | undefined;
7
- controller?: import("./types").OperationController | undefined;
8
- } | undefined) => typeof execute;
6
+ execute?: typeof execute;
7
+ controller?: import("./types").OperationController;
8
+ }) => 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 | undefined;
7
- controller?: import("./types").OperationController | undefined;
8
- } | undefined) => typeof subscribe;
6
+ subscribe?: typeof subscribe;
7
+ controller?: import("./types").OperationController;
8
+ }) => typeof subscribe;
package/index.js CHANGED
@@ -2,11 +2,8 @@
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
-
7
5
  const schema = require('@graphql-tools/schema');
8
6
  const graphql = require('graphql');
9
- const module$1 = _interopDefault(require('module'));
10
7
  const wrap = require('@graphql-tools/wrap');
11
8
  const ramda = require('ramda');
12
9
 
@@ -735,9 +732,9 @@ function tapAsyncIterator(iterable, doneCallback) {
735
732
  throw error;
736
733
  }
737
734
  },
738
- async return() {
735
+ async return(value) {
739
736
  try {
740
- const result = await iterator.return();
737
+ const result = await iterator.return(value);
741
738
  return mapResult(result);
742
739
  }
743
740
  catch (error) {
@@ -745,13 +742,16 @@ function tapAsyncIterator(iterable, doneCallback) {
745
742
  throw error;
746
743
  }
747
744
  },
748
- async throw(error) {
745
+ throw(error) {
749
746
  doneCallback();
750
747
  return iterator.throw(error);
751
748
  },
752
749
  [Symbol.asyncIterator]() {
753
750
  return this;
754
751
  },
752
+ [Symbol.asyncDispose]() {
753
+ return iterator[Symbol.asyncDispose]();
754
+ },
755
755
  };
756
756
  }
757
757
  function once(cb) {
@@ -840,23 +840,6 @@ function duplicatedGlobalTokenError(provider, modules) {
840
840
  ].join(' '));
841
841
  }
842
842
 
843
- let alc;
844
- if (typeof process !== 'undefined') {
845
- // probably nodejs runtime
846
- const require = module$1.createRequire('file:///' /** path is not relevant since we're only loading a builtin */);
847
- const hooks = require('async_hooks');
848
- alc = new hooks.AsyncLocalStorage();
849
- }
850
- function getAsyncContext() {
851
- return alc === null || alc === void 0 ? void 0 : alc.getStore();
852
- }
853
- function runWithAsyncContext(asyncContext, callback, ...args) {
854
- if (!alc) {
855
- return callback(...args);
856
- }
857
- return alc.run(asyncContext, callback, ...args);
858
- }
859
-
860
843
  /**
861
844
  * @api
862
845
  * `CONTEXT` is an InjectionToken representing the provided `GraphQLModules.GlobalContext`
@@ -902,14 +885,11 @@ function createContextBuilder({ appInjector, modulesMap, appLevelOperationProvid
902
885
  },
903
886
  });
904
887
  appInjector.setExecutionContextGetter(function executionContextGetter() {
905
- var _a;
906
- return ((_a = getAsyncContext()) === null || _a === void 0 ? void 0 : _a.getApplicationContext()) || appContext;
888
+ return appContext;
907
889
  });
908
890
  function createModuleExecutionContextGetter(moduleId) {
909
891
  return function moduleExecutionContextGetter() {
910
- var _a;
911
- return (((_a = getAsyncContext()) === null || _a === void 0 ? void 0 : _a.getModuleContext(moduleId)) ||
912
- getModuleContext(moduleId, context));
892
+ return getModuleContext(moduleId, context);
913
893
  };
914
894
  }
915
895
  modulesMap.forEach((mod, moduleId) => {
@@ -979,7 +959,7 @@ function createContextBuilder({ appInjector, modulesMap, appLevelOperationProvid
979
959
  return getModuleContext(moduleId, sharedContext).injector;
980
960
  },
981
961
  });
982
- const env = {
962
+ return {
983
963
  ɵdestroy: once(() => {
984
964
  providersToDestroy.forEach(([injector, keyId]) => {
985
965
  // If provider was instantiated
@@ -993,19 +973,6 @@ function createContextBuilder({ appInjector, modulesMap, appLevelOperationProvid
993
973
  ɵinjector: operationAppInjector,
994
974
  context: sharedContext,
995
975
  };
996
- return {
997
- ...env,
998
- runWithContext(cb) {
999
- return runWithAsyncContext({
1000
- getApplicationContext() {
1001
- return appContext;
1002
- },
1003
- getModuleContext(moduleId) {
1004
- return getModuleContext(moduleId, context);
1005
- },
1006
- }, cb, env);
1007
- },
1008
- };
1009
976
  };
1010
977
  return contextBuilder;
1011
978
  }
@@ -1015,34 +982,31 @@ function executionCreator({ contextBuilder, }) {
1015
982
  // Custom or original execute function
1016
983
  const executeFn = (options === null || options === void 0 ? void 0 : options.execute) || graphql.execute;
1017
984
  return (argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) => {
1018
- function perform({ context, ɵdestroy: destroy, }) {
1019
- const executionArgs = 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
- typeResolver,
1033
- };
1034
- // It's important to wrap the executeFn within a promise
1035
- // so we can easily control the end of execution (with finally)
1036
- return Promise.resolve()
1037
- .then(() => executeFn(executionArgs))
1038
- .finally(destroy);
1039
- }
1040
- if (options === null || options === void 0 ? void 0 : options.controller) {
1041
- return perform(options.controller);
1042
- }
1043
- return contextBuilder(isNotSchema(argsOrSchema)
985
+ var _a;
986
+ // Create an execution context
987
+ const { context, ɵdestroy: destroy } = (_a = options === null || options === void 0 ? void 0 : options.controller) !== null && _a !== void 0 ? _a : contextBuilder(isNotSchema(argsOrSchema)
1044
988
  ? argsOrSchema.contextValue
1045
- : contextValue).runWithContext(perform);
989
+ : contextValue);
990
+ const executionArgs = isNotSchema(argsOrSchema)
991
+ ? {
992
+ ...argsOrSchema,
993
+ contextValue: context,
994
+ }
995
+ : {
996
+ schema: argsOrSchema,
997
+ document: document,
998
+ rootValue,
999
+ contextValue: context,
1000
+ variableValues,
1001
+ operationName,
1002
+ fieldResolver,
1003
+ typeResolver,
1004
+ };
1005
+ // It's important to wrap the executeFn within a promise
1006
+ // so we can easily control the end of execution (with finally)
1007
+ return Promise.resolve()
1008
+ .then(() => executeFn(executionArgs))
1009
+ .finally(destroy);
1046
1010
  };
1047
1011
  };
1048
1012
  return createExecution;
@@ -1053,46 +1017,43 @@ function subscriptionCreator({ contextBuilder, }) {
1053
1017
  // Custom or original subscribe function
1054
1018
  const subscribeFn = (options === null || options === void 0 ? void 0 : options.subscribe) || graphql.subscribe;
1055
1019
  return (argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver) => {
1056
- function perform({ context, ɵdestroy: destroy, }) {
1057
- const subscriptionArgs = isNotSchema(argsOrSchema)
1058
- ? {
1059
- ...argsOrSchema,
1060
- contextValue: context,
1061
- }
1062
- : {
1063
- schema: argsOrSchema,
1064
- document: document,
1065
- rootValue,
1066
- contextValue: context,
1067
- variableValues,
1068
- operationName,
1069
- fieldResolver,
1070
- subscribeFieldResolver,
1071
- };
1072
- let isIterable = false;
1073
- // It's important to wrap the subscribeFn within a promise
1074
- // so we can easily control the end of subscription (with finally)
1075
- return Promise.resolve()
1076
- .then(() => subscribeFn(subscriptionArgs))
1077
- .then((sub) => {
1078
- if (isAsyncIterable(sub)) {
1079
- isIterable = true;
1080
- return tapAsyncIterator(sub, destroy);
1081
- }
1082
- return sub;
1083
- })
1084
- .finally(() => {
1085
- if (!isIterable) {
1086
- destroy();
1087
- }
1088
- });
1089
- }
1090
- if (options === null || options === void 0 ? void 0 : options.controller) {
1091
- return perform(options.controller);
1092
- }
1093
- return contextBuilder(isNotSchema(argsOrSchema)
1020
+ var _a;
1021
+ // Create an subscription context
1022
+ const { context, ɵdestroy: destroy } = (_a = options === null || options === void 0 ? void 0 : options.controller) !== null && _a !== void 0 ? _a : contextBuilder(isNotSchema(argsOrSchema)
1094
1023
  ? argsOrSchema.contextValue
1095
- : contextValue).runWithContext(perform);
1024
+ : contextValue);
1025
+ const subscriptionArgs = isNotSchema(argsOrSchema)
1026
+ ? {
1027
+ ...argsOrSchema,
1028
+ contextValue: context,
1029
+ }
1030
+ : {
1031
+ schema: argsOrSchema,
1032
+ document: document,
1033
+ rootValue,
1034
+ contextValue: context,
1035
+ variableValues,
1036
+ operationName,
1037
+ fieldResolver,
1038
+ subscribeFieldResolver,
1039
+ };
1040
+ let isIterable = false;
1041
+ // It's important to wrap the subscribeFn within a promise
1042
+ // so we can easily control the end of subscription (with finally)
1043
+ return Promise.resolve()
1044
+ .then(() => subscribeFn(subscriptionArgs))
1045
+ .then((sub) => {
1046
+ if (isAsyncIterable(sub)) {
1047
+ isIterable = true;
1048
+ return tapAsyncIterator(sub, destroy);
1049
+ }
1050
+ return sub;
1051
+ })
1052
+ .finally(() => {
1053
+ if (!isIterable) {
1054
+ destroy();
1055
+ }
1056
+ });
1096
1057
  };
1097
1058
  };
1098
1059
  return createSubscription;
@@ -1117,9 +1078,10 @@ function apolloSchemaCreator({ createSubscription, contextBuilder, schema, }) {
1117
1078
  const createApolloSchema = () => {
1118
1079
  const sessions = {};
1119
1080
  const subscription = createSubscription();
1120
- function getSession(ctx, { context, ɵdestroy: destroy }) {
1081
+ function getSession(ctx) {
1121
1082
  if (!ctx[CONTEXT_ID]) {
1122
1083
  ctx[CONTEXT_ID] = uniqueId((id) => !sessions[id]);
1084
+ const { context, ɵdestroy: destroy } = contextBuilder(ctx);
1123
1085
  sessions[ctx[CONTEXT_ID]] = {
1124
1086
  count: 0,
1125
1087
  session: {
@@ -1151,22 +1113,20 @@ function apolloSchemaCreator({ createSubscription, contextBuilder, schema, }) {
1151
1113
  operationName: input.operationName,
1152
1114
  });
1153
1115
  }
1154
- // Create an execution context and run within it
1155
- return contextBuilder(input.context).runWithContext((env) => {
1156
- const { context, destroy } = getSession(input.context, env);
1157
- // It's important to wrap the executeFn within a promise
1158
- // so we can easily control the end of execution (with finally)
1159
- return Promise.resolve()
1160
- .then(() => graphql.execute({
1161
- schema,
1162
- document: input.document,
1163
- contextValue: context,
1164
- variableValues: input.variables,
1165
- rootValue: input.rootValue,
1166
- operationName: input.operationName,
1167
- }))
1168
- .finally(destroy);
1169
- });
1116
+ // Create an execution context
1117
+ const { context, destroy } = getSession(input.context);
1118
+ // It's important to wrap the executeFn within a promise
1119
+ // so we can easily control the end of execution (with finally)
1120
+ return Promise.resolve()
1121
+ .then(() => graphql.execute({
1122
+ schema,
1123
+ document: input.document,
1124
+ contextValue: context,
1125
+ variableValues: input.variables,
1126
+ rootValue: input.rootValue,
1127
+ operationName: input.operationName,
1128
+ }))
1129
+ .finally(destroy);
1170
1130
  },
1171
1131
  });
1172
1132
  };
package/index.mjs CHANGED
@@ -1,6 +1,5 @@
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 module$1 from 'module';
4
3
  import { wrapSchema } from '@graphql-tools/wrap';
5
4
  import { mergeDeepWith } from 'ramda';
6
5
 
@@ -730,9 +729,9 @@ function tapAsyncIterator(iterable, doneCallback) {
730
729
  throw error;
731
730
  }
732
731
  },
733
- async return() {
732
+ async return(value) {
734
733
  try {
735
- const result = await iterator.return();
734
+ const result = await iterator.return(value);
736
735
  return mapResult(result);
737
736
  }
738
737
  catch (error) {
@@ -740,13 +739,16 @@ function tapAsyncIterator(iterable, doneCallback) {
740
739
  throw error;
741
740
  }
742
741
  },
743
- async throw(error) {
742
+ throw(error) {
744
743
  doneCallback();
745
744
  return iterator.throw(error);
746
745
  },
747
746
  [Symbol.asyncIterator]() {
748
747
  return this;
749
748
  },
749
+ [Symbol.asyncDispose]() {
750
+ return iterator[Symbol.asyncDispose]();
751
+ },
750
752
  };
751
753
  }
752
754
  function once(cb) {
@@ -835,23 +837,6 @@ function duplicatedGlobalTokenError(provider, modules) {
835
837
  ].join(' '));
836
838
  }
837
839
 
838
- let alc;
839
- if (typeof process !== 'undefined') {
840
- // probably nodejs runtime
841
- const require = module$1.createRequire('file:///' /** path is not relevant since we're only loading a builtin */);
842
- const hooks = require('async_hooks');
843
- alc = new hooks.AsyncLocalStorage();
844
- }
845
- function getAsyncContext() {
846
- return alc === null || alc === void 0 ? void 0 : alc.getStore();
847
- }
848
- function runWithAsyncContext(asyncContext, callback, ...args) {
849
- if (!alc) {
850
- return callback(...args);
851
- }
852
- return alc.run(asyncContext, callback, ...args);
853
- }
854
-
855
840
  /**
856
841
  * @api
857
842
  * `CONTEXT` is an InjectionToken representing the provided `GraphQLModules.GlobalContext`
@@ -897,14 +882,11 @@ function createContextBuilder({ appInjector, modulesMap, appLevelOperationProvid
897
882
  },
898
883
  });
899
884
  appInjector.setExecutionContextGetter(function executionContextGetter() {
900
- var _a;
901
- return ((_a = getAsyncContext()) === null || _a === void 0 ? void 0 : _a.getApplicationContext()) || appContext;
885
+ return appContext;
902
886
  });
903
887
  function createModuleExecutionContextGetter(moduleId) {
904
888
  return function moduleExecutionContextGetter() {
905
- var _a;
906
- return (((_a = getAsyncContext()) === null || _a === void 0 ? void 0 : _a.getModuleContext(moduleId)) ||
907
- getModuleContext(moduleId, context));
889
+ return getModuleContext(moduleId, context);
908
890
  };
909
891
  }
910
892
  modulesMap.forEach((mod, moduleId) => {
@@ -974,7 +956,7 @@ function createContextBuilder({ appInjector, modulesMap, appLevelOperationProvid
974
956
  return getModuleContext(moduleId, sharedContext).injector;
975
957
  },
976
958
  });
977
- const env = {
959
+ return {
978
960
  ɵdestroy: once(() => {
979
961
  providersToDestroy.forEach(([injector, keyId]) => {
980
962
  // If provider was instantiated
@@ -988,19 +970,6 @@ function createContextBuilder({ appInjector, modulesMap, appLevelOperationProvid
988
970
  ɵinjector: operationAppInjector,
989
971
  context: sharedContext,
990
972
  };
991
- return {
992
- ...env,
993
- runWithContext(cb) {
994
- return runWithAsyncContext({
995
- getApplicationContext() {
996
- return appContext;
997
- },
998
- getModuleContext(moduleId) {
999
- return getModuleContext(moduleId, context);
1000
- },
1001
- }, cb, env);
1002
- },
1003
- };
1004
973
  };
1005
974
  return contextBuilder;
1006
975
  }
@@ -1010,34 +979,31 @@ function executionCreator({ contextBuilder, }) {
1010
979
  // Custom or original execute function
1011
980
  const executeFn = (options === null || options === void 0 ? void 0 : options.execute) || execute$1;
1012
981
  return (argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) => {
1013
- function perform({ context, ɵdestroy: destroy, }) {
1014
- const executionArgs = isNotSchema(argsOrSchema)
1015
- ? {
1016
- ...argsOrSchema,
1017
- contextValue: context,
1018
- }
1019
- : {
1020
- schema: argsOrSchema,
1021
- document: document,
1022
- rootValue,
1023
- contextValue: context,
1024
- variableValues,
1025
- operationName,
1026
- fieldResolver,
1027
- typeResolver,
1028
- };
1029
- // It's important to wrap the executeFn within a promise
1030
- // so we can easily control the end of execution (with finally)
1031
- return Promise.resolve()
1032
- .then(() => executeFn(executionArgs))
1033
- .finally(destroy);
1034
- }
1035
- if (options === null || options === void 0 ? void 0 : options.controller) {
1036
- return perform(options.controller);
1037
- }
1038
- return contextBuilder(isNotSchema(argsOrSchema)
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)
1039
985
  ? argsOrSchema.contextValue
1040
- : contextValue).runWithContext(perform);
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);
1041
1007
  };
1042
1008
  };
1043
1009
  return createExecution;
@@ -1048,46 +1014,43 @@ function subscriptionCreator({ contextBuilder, }) {
1048
1014
  // Custom or original subscribe function
1049
1015
  const subscribeFn = (options === null || options === void 0 ? void 0 : options.subscribe) || subscribe;
1050
1016
  return (argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver) => {
1051
- function perform({ context, ɵdestroy: destroy, }) {
1052
- const subscriptionArgs = isNotSchema(argsOrSchema)
1053
- ? {
1054
- ...argsOrSchema,
1055
- contextValue: context,
1056
- }
1057
- : {
1058
- schema: argsOrSchema,
1059
- document: document,
1060
- rootValue,
1061
- contextValue: context,
1062
- variableValues,
1063
- operationName,
1064
- fieldResolver,
1065
- subscribeFieldResolver,
1066
- };
1067
- let isIterable = false;
1068
- // It's important to wrap the subscribeFn within a promise
1069
- // so we can easily control the end of subscription (with finally)
1070
- return Promise.resolve()
1071
- .then(() => subscribeFn(subscriptionArgs))
1072
- .then((sub) => {
1073
- if (isAsyncIterable(sub)) {
1074
- isIterable = true;
1075
- return tapAsyncIterator(sub, destroy);
1076
- }
1077
- return sub;
1078
- })
1079
- .finally(() => {
1080
- if (!isIterable) {
1081
- destroy();
1082
- }
1083
- });
1084
- }
1085
- if (options === null || options === void 0 ? void 0 : options.controller) {
1086
- return perform(options.controller);
1087
- }
1088
- return contextBuilder(isNotSchema(argsOrSchema)
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)
1089
1020
  ? argsOrSchema.contextValue
1090
- : contextValue).runWithContext(perform);
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
+ });
1091
1054
  };
1092
1055
  };
1093
1056
  return createSubscription;
@@ -1112,9 +1075,10 @@ function apolloSchemaCreator({ createSubscription, contextBuilder, schema, }) {
1112
1075
  const createApolloSchema = () => {
1113
1076
  const sessions = {};
1114
1077
  const subscription = createSubscription();
1115
- function getSession(ctx, { context, ɵdestroy: destroy }) {
1078
+ function getSession(ctx) {
1116
1079
  if (!ctx[CONTEXT_ID]) {
1117
1080
  ctx[CONTEXT_ID] = uniqueId((id) => !sessions[id]);
1081
+ const { context, ɵdestroy: destroy } = contextBuilder(ctx);
1118
1082
  sessions[ctx[CONTEXT_ID]] = {
1119
1083
  count: 0,
1120
1084
  session: {
@@ -1146,22 +1110,20 @@ function apolloSchemaCreator({ createSubscription, contextBuilder, schema, }) {
1146
1110
  operationName: input.operationName,
1147
1111
  });
1148
1112
  }
1149
- // Create an execution context and run within it
1150
- return contextBuilder(input.context).runWithContext((env) => {
1151
- const { context, destroy } = getSession(input.context, env);
1152
- // It's important to wrap the executeFn within a promise
1153
- // so we can easily control the end of execution (with finally)
1154
- return Promise.resolve()
1155
- .then(() => execute$1({
1156
- schema,
1157
- document: input.document,
1158
- contextValue: context,
1159
- variableValues: input.variables,
1160
- rootValue: input.rootValue,
1161
- operationName: input.operationName,
1162
- }))
1163
- .finally(destroy);
1164
- });
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(() => execute$1({
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);
1165
1127
  },
1166
1128
  });
1167
1129
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphql-modules",
3
- "version": "2.4.1-alpha-20241224125233-8750a83885a9c3564903d48a639541391c8e9a6d",
3
+ "version": "2.4.1-alpha-20250121000023-bfc739c20cae990e57c710f62c520fe7ac7246a2",
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.29.0"
13
+ "ramda": "^0.30.0"
14
14
  },
15
15
  "keywords": [
16
16
  "graphql",
@@ -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<any>) => Promise<any>;
19
+ export declare function createMiddleware(path: string[], middlewareMap?: MiddlewareMap): (context: MiddlewareContext, next: Next) => 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>(iterable: AsyncIterable<T>, doneCallback: () => void): AsyncGenerator<T>;
7
+ export declare function tapAsyncIterator<T>(iterable: AsyncGenerator<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;
@@ -1,6 +0,0 @@
1
- export interface AsyncContext {
2
- getApplicationContext(): GraphQLModules.AppContext;
3
- getModuleContext(moduleId: string): GraphQLModules.ModuleContext;
4
- }
5
- export declare function getAsyncContext(): AsyncContext | undefined;
6
- export declare function runWithAsyncContext<R, TArgs extends any[]>(asyncContext: AsyncContext, callback: (...args: TArgs) => R, ...args: TArgs): R;