@inversifyjs/apollo-express 0.2.0

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.
Files changed (28) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +3 -0
  3. package/lib/esm/apollo/controllers/buildApolloServerExpressController.d.ts +7 -0
  4. package/lib/esm/apollo/controllers/buildApolloServerExpressController.d.ts.map +1 -0
  5. package/lib/esm/apollo/controllers/buildApolloServerExpressController.int.spec.d.ts +2 -0
  6. package/lib/esm/apollo/controllers/buildApolloServerExpressController.int.spec.d.ts.map +1 -0
  7. package/lib/esm/apollo/controllers/buildApolloServerExpressController.js +34 -0
  8. package/lib/esm/apollo/controllers/buildApolloServerExpressController.js.map +1 -0
  9. package/lib/esm/apollo/models/ApolloExpressControllerOptions.d.ts +8 -0
  10. package/lib/esm/apollo/models/ApolloExpressControllerOptions.d.ts.map +1 -0
  11. package/lib/esm/apollo/models/ApolloExpressControllerOptions.js +2 -0
  12. package/lib/esm/apollo/models/ApolloExpressControllerOptions.js.map +1 -0
  13. package/lib/esm/apollo/models/ApolloServerInjectOptions.d.ts +8 -0
  14. package/lib/esm/apollo/models/ApolloServerInjectOptions.d.ts.map +1 -0
  15. package/lib/esm/apollo/models/ApolloServerInjectOptions.js +2 -0
  16. package/lib/esm/apollo/models/ApolloServerInjectOptions.js.map +1 -0
  17. package/lib/esm/apollo/modules/ApolloExpressServerContainerModule.d.ts +8 -0
  18. package/lib/esm/apollo/modules/ApolloExpressServerContainerModule.d.ts.map +1 -0
  19. package/lib/esm/apollo/modules/ApolloExpressServerContainerModule.js +26 -0
  20. package/lib/esm/apollo/modules/ApolloExpressServerContainerModule.js.map +1 -0
  21. package/lib/esm/apollo/modules/ApolloExpressServerContainerModule.spec.d.ts +2 -0
  22. package/lib/esm/apollo/modules/ApolloExpressServerContainerModule.spec.d.ts.map +1 -0
  23. package/lib/esm/index.d.ts +4 -0
  24. package/lib/esm/index.d.ts.map +1 -0
  25. package/lib/esm/index.js +2 -0
  26. package/lib/esm/index.js.map +1 -0
  27. package/package.json +69 -0
  28. package/tsconfig.esm.json +10 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # @inversifyjs/apollo-express
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added `buildApolloServerExpressController`
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @inversifyjs/apollo-core@0.2.0
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @inversifyjs/apollo-express
2
+
3
+ Inversify GraphQL Apollo express modules.
@@ -0,0 +1,7 @@
1
+ import { type BaseContext } from '@apollo/server';
2
+ import { ExpressContextFunctionArgument } from '@as-integrations/express5';
3
+ import { ApolloServerController } from '@inversifyjs/apollo-core';
4
+ import { Newable } from 'inversify';
5
+ import { ApolloServerExpressControllerOptions } from '../models/ApolloExpressControllerOptions.js';
6
+ export default function buildApolloServerExpressController<TContext extends BaseContext = BaseContext>(options: ApolloServerExpressControllerOptions<TContext>): Newable<ApolloServerController<TContext, [ExpressContextFunctionArgument]>>;
7
+ //# sourceMappingURL=buildApolloServerExpressController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildApolloServerExpressController.d.ts","sourceRoot":"","sources":["../../../../src/apollo/controllers/buildApolloServerExpressController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EACL,8BAA8B,EAE/B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,sBAAsB,EAEvB,MAAM,0BAA0B,CAAC;AASlC,OAAO,EAAU,OAAO,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,oCAAoC,EAAE,MAAM,6CAA6C,CAAC;AAEnG,MAAM,CAAC,OAAO,UAAU,kCAAkC,CACxD,QAAQ,SAAS,WAAW,GAAG,WAAW,EAE1C,OAAO,EAAE,oCAAoC,CAAC,QAAQ,CAAC,GACtD,OAAO,CAAC,sBAAsB,CAAC,QAAQ,EAAE,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAuC7E"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=buildApolloServerExpressController.int.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildApolloServerExpressController.int.spec.d.ts","sourceRoot":"","sources":["../../../../src/apollo/controllers/buildApolloServerExpressController.int.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,34 @@
1
+ import { __decorate, __param } from "tslib";
2
+ import { expressMiddleware, } from '@as-integrations/express5';
3
+ import { ApolloServerController, apolloServerServiceIdentifier, } from '@inversifyjs/apollo-core';
4
+ import { Controller, Next, Post, Request, Response, } from '@inversifyjs/http-core';
5
+ import { inject } from 'inversify';
6
+ export default function buildApolloServerExpressController(options) {
7
+ let ApolloServerExpressController = class ApolloServerExpressController extends ApolloServerController {
8
+ #middleware;
9
+ constructor(apolloServer) {
10
+ super();
11
+ this.#middleware = expressMiddleware(apolloServer, {
12
+ context: this._getContext.bind(this),
13
+ });
14
+ }
15
+ async handleRequest(req, res, next) {
16
+ return this.#middleware(req, res, next);
17
+ }
18
+ async _getContext(arg) {
19
+ return options.getContext(arg);
20
+ }
21
+ };
22
+ __decorate([
23
+ Post(),
24
+ __param(0, Request()),
25
+ __param(1, Response()),
26
+ __param(2, Next())
27
+ ], ApolloServerExpressController.prototype, "handleRequest", null);
28
+ ApolloServerExpressController = __decorate([
29
+ Controller(options.controllerOptions),
30
+ __param(0, inject(apolloServerServiceIdentifier))
31
+ ], ApolloServerExpressController);
32
+ return ApolloServerExpressController;
33
+ }
34
+ //# sourceMappingURL=buildApolloServerExpressController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildApolloServerExpressController.js","sourceRoot":"","sources":["../../../../src/apollo/controllers/buildApolloServerExpressController.ts"],"names":[],"mappings":";AACA,OAAO,EAEL,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,sBAAsB,EACtB,6BAA6B,GAC9B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,QAAQ,GACT,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,MAAM,EAAW,MAAM,WAAW,CAAC;AAI5C,MAAM,CAAC,OAAO,UAAU,kCAAkC,CAGxD,OAAuD;IAGvD,IAAM,6BAA6B,GAAnC,MAAM,6BAA8B,SAAQ,sBAG3C;QACU,WAAW,CAAyB;QAE7C,YAEE,YAAoC;YAEpC,KAAK,EAAE,CAAC;YAER,IAAI,CAAC,WAAW,GAAG,iBAAiB,CAAW,YAAY,EAAE;gBAC3D,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;aACrC,CAAC,CAAC;QACL,CAAC;QAGY,AAAN,KAAK,CAAC,aAAa,CAExB,GAAoB,EAEpB,GAAqB,EAErB,IAA0B;YAE1B,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAC1C,CAAC;QAES,KAAK,CAAC,WAAW,CACzB,GAAmC;YAEnC,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC;KACF,CAAA;IAhBc;QADZ,IAAI,EAAE;QAEJ,WAAA,OAAO,EAAE,CAAA;QAET,WAAA,QAAQ,EAAE,CAAA;QAEV,WAAA,IAAI,EAAE,CAAA;sEAIR;IA3BG,6BAA6B;QADlC,UAAU,CAAC,OAAO,CAAC,iBAAiB,CAAC;QAQjC,WAAA,MAAM,CAAC,6BAA6B,CAAC,CAAA;OAPpC,6BAA6B,CAkClC;IAED,OAAO,6BAA6B,CAAC;AACvC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type BaseContext } from '@apollo/server';
2
+ import { type ExpressContextFunctionArgument } from '@as-integrations/express5';
3
+ import { type ControllerOptions } from '@inversifyjs/http-core';
4
+ export interface ApolloServerExpressControllerOptions<TContext extends BaseContext> {
5
+ controllerOptions?: string | ControllerOptions | undefined;
6
+ getContext: (arg: ExpressContextFunctionArgument) => Promise<TContext>;
7
+ }
8
+ //# sourceMappingURL=ApolloExpressControllerOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApolloExpressControllerOptions.d.ts","sourceRoot":"","sources":["../../../../src/apollo/models/ApolloExpressControllerOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,MAAM,WAAW,oCAAoC,CACnD,QAAQ,SAAS,WAAW;IAE5B,iBAAiB,CAAC,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAAC;IAC3D,UAAU,EAAE,CAAC,GAAG,EAAE,8BAA8B,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;CACxE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ApolloExpressControllerOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApolloExpressControllerOptions.js","sourceRoot":"","sources":["../../../../src/apollo/models/ApolloExpressControllerOptions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { type ApolloServerPlugin, type BaseContext } from '@apollo/server';
2
+ import { type IResolvers, type TypeSource } from '@graphql-tools/utils';
3
+ export interface ApolloServerInjectOptions<TContext extends BaseContext> {
4
+ plugins?: ApolloServerPlugin<TContext>[] | undefined;
5
+ resolvers: IResolvers<TContext>;
6
+ typeDefs: TypeSource;
7
+ }
8
+ //# sourceMappingURL=ApolloServerInjectOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApolloServerInjectOptions.d.ts","sourceRoot":"","sources":["../../../../src/apollo/models/ApolloServerInjectOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAExE,MAAM,WAAW,yBAAyB,CAAC,QAAQ,SAAS,WAAW;IACrE,OAAO,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,EAAE,GAAG,SAAS,CAAC;IACrD,SAAS,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IAChC,QAAQ,EAAE,UAAU,CAAC;CACtB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ApolloServerInjectOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApolloServerInjectOptions.js","sourceRoot":"","sources":["../../../../src/apollo/models/ApolloServerInjectOptions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { type BaseContext } from '@apollo/server';
2
+ import { ApolloServerContainerModule } from '@inversifyjs/apollo-core';
3
+ import { ApolloServerExpressControllerOptions } from '../models/ApolloExpressControllerOptions.js';
4
+ import { ApolloServerInjectOptions } from '../models/ApolloServerInjectOptions.js';
5
+ export default class ApolloExpressServerContainerModule extends ApolloServerContainerModule {
6
+ static forOptions<TContext extends BaseContext>(controllerOptions: ApolloServerExpressControllerOptions<TContext>, serverOptions: ApolloServerInjectOptions<TContext>): ApolloExpressServerContainerModule;
7
+ }
8
+ //# sourceMappingURL=ApolloExpressServerContainerModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApolloExpressServerContainerModule.d.ts","sourceRoot":"","sources":["../../../../src/apollo/modules/ApolloExpressServerContainerModule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EACL,2BAA2B,EAI5B,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EAAE,oCAAoC,EAAE,MAAM,6CAA6C,CAAC;AACnG,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AAEnF,MAAM,CAAC,OAAO,OAAO,kCAAmC,SAAQ,2BAA2B;WAC3E,UAAU,CAAC,QAAQ,SAAS,WAAW,EACnD,iBAAiB,EAAE,oCAAoC,CAAC,QAAQ,CAAC,EACjE,aAAa,EAAE,yBAAyB,CAAC,QAAQ,CAAC,GACjD,kCAAkC;CA2BtC"}
@@ -0,0 +1,26 @@
1
+ import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer';
2
+ import { ApolloServerContainerModule, apolloServerPluginsServiceIdentifier, apolloServerResolversServiceIdentifier, apolloServerTypeDefsServiceIdentifier, } from '@inversifyjs/apollo-core';
3
+ import { httpServerServiceIdentifier } from '@inversifyjs/http-core';
4
+ import buildApolloServerExpressController from '../controllers/buildApolloServerExpressController.js';
5
+ export default class ApolloExpressServerContainerModule extends ApolloServerContainerModule {
6
+ static forOptions(controllerOptions, serverOptions) {
7
+ return new ApolloExpressServerContainerModule((options) => {
8
+ options
9
+ .bind(buildApolloServerExpressController(controllerOptions))
10
+ .toSelf();
11
+ options
12
+ .bind(apolloServerPluginsServiceIdentifier)
13
+ .toResolvedValue((httpServer) => [
14
+ ...(serverOptions.plugins ?? []),
15
+ ApolloServerPluginDrainHttpServer({ httpServer }),
16
+ ], [httpServerServiceIdentifier]);
17
+ options
18
+ .bind(apolloServerResolversServiceIdentifier)
19
+ .toConstantValue(serverOptions.resolvers);
20
+ options
21
+ .bind(apolloServerTypeDefsServiceIdentifier)
22
+ .toConstantValue(serverOptions.typeDefs);
23
+ });
24
+ }
25
+ }
26
+ //# sourceMappingURL=ApolloExpressServerContainerModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApolloExpressServerContainerModule.js","sourceRoot":"","sources":["../../../../src/apollo/modules/ApolloExpressServerContainerModule.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iCAAiC,EAAE,MAAM,uCAAuC,CAAC;AAC1F,OAAO,EACL,2BAA2B,EAC3B,oCAAoC,EACpC,sCAAsC,EACtC,qCAAqC,GACtC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAGrE,OAAO,kCAAkC,MAAM,sDAAsD,CAAC;AAItG,MAAM,CAAC,OAAO,OAAO,kCAAmC,SAAQ,2BAA2B;IAClF,MAAM,CAAC,UAAU,CACtB,iBAAiE,EACjE,aAAkD;QAElD,OAAO,IAAI,kCAAkC,CAC3C,CAAC,OAAmC,EAAQ,EAAE;YAC5C,OAAO;iBACJ,IAAI,CAAC,kCAAkC,CAAC,iBAAiB,CAAC,CAAC;iBAC3D,MAAM,EAAE,CAAC;YAEZ,OAAO;iBACJ,IAAI,CAAC,oCAAoC,CAAC;iBAC1C,eAAe,CACd,CAAC,UAAuB,EAAE,EAAE,CAAC;gBAC3B,GAAG,CAAC,aAAa,CAAC,OAAO,IAAI,EAAE,CAAC;gBAChC,iCAAiC,CAAC,EAAE,UAAU,EAAE,CAAC;aAClD,EACD,CAAC,2BAA2B,CAAC,CAC9B,CAAC;YAEJ,OAAO;iBACJ,IAAI,CAAC,sCAAsC,CAAC;iBAC5C,eAAe,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;YAE5C,OAAO;iBACJ,IAAI,CAAC,qCAAqC,CAAC;iBAC3C,eAAe,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC,CACF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ApolloExpressServerContainerModule.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApolloExpressServerContainerModule.spec.d.ts","sourceRoot":"","sources":["../../../../src/apollo/modules/ApolloExpressServerContainerModule.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export { type ApolloServerExpressControllerOptions } from './apollo/models/ApolloExpressControllerOptions.js';
2
+ export { type ApolloServerInjectOptions } from './apollo/models/ApolloServerInjectOptions.js';
3
+ export { default as ApolloExpressServerContainerModule } from './apollo/modules/ApolloExpressServerContainerModule.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oCAAoC,EAAE,MAAM,mDAAmD,CAAC;AAC9G,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AAC9F,OAAO,EAAE,OAAO,IAAI,kCAAkC,EAAE,MAAM,wDAAwD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default as ApolloExpressServerContainerModule } from './apollo/modules/ApolloExpressServerContainerModule.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,kCAAkC,EAAE,MAAM,wDAAwD,CAAC"}
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "author": "Roberto Pintos López",
3
+ "bugs": {
4
+ "url": "https://github.com/inversify/graphql/issues"
5
+ },
6
+ "description": "InversifyJs GraphQL Apollo express package",
7
+ "dependencies": {
8
+ "@as-integrations/express5": "^1.1.2",
9
+ "@inversifyjs/apollo-core": "0.2.0"
10
+ },
11
+ "devDependencies": {
12
+ "@inversifyjs/http-express": "4.9.0",
13
+ "@graphql-tools/utils": "10.11.0",
14
+ "@types/express": "^5.0.6",
15
+ "@types/node": "24.10.4",
16
+ "@vitest/coverage-v8": "4.0.16",
17
+ "eslint": "9.39.2",
18
+ "prettier": "3.7.4",
19
+ "rimraf": "6.1.2",
20
+ "tslib": "2.8.1",
21
+ "typescript": "5.9.3",
22
+ "vitest": "4.0.16"
23
+ },
24
+ "homepage": "https://inversify.io/framework/",
25
+ "keywords": [
26
+ "apollo",
27
+ "inversify",
28
+ "graphql",
29
+ "http",
30
+ "node",
31
+ "typescript"
32
+ ],
33
+ "devEngines": {
34
+ "node": "^24.10.0",
35
+ "pnpm": "^10.13.1"
36
+ },
37
+ "license": "MIT",
38
+ "module": "lib/esm/index.js",
39
+ "exports": {
40
+ ".": "./lib/esm/index.js"
41
+ },
42
+ "name": "@inversifyjs/apollo-express",
43
+ "peerDependencies": {
44
+ "@apollo/server": "^5.2.0",
45
+ "@inversifyjs/http-core": "^4.9.0",
46
+ "inversify": "^7.10.8"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
50
+ },
51
+ "repository": {
52
+ "type": "git",
53
+ "url": "git+https://github.com/inversify/graphql.git"
54
+ },
55
+ "type": "module",
56
+ "version": "0.2.0",
57
+ "scripts": {
58
+ "build": "tsc",
59
+ "build:clean": "rimraf lib",
60
+ "format": "prettier --write ./src",
61
+ "lint": "eslint ./src",
62
+ "prebuild": "pnpm run build:clean",
63
+ "test": "vitest run",
64
+ "test:integration": "pnpm run test --project Integration",
65
+ "test:coverage": "pnpm run test:unit --coverage",
66
+ "test:uncommitted": "pnpm run test --changed=HEAD",
67
+ "test:unit": "pnpm run test --project Unit"
68
+ }
69
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "http://json.schemastore.org/tsconfig",
3
+ "extends": "@inversifyjs/foundation-typescript-config/tsconfig.base.esm.json",
4
+ "compilerOptions": {
5
+ "outDir": "./lib/esm",
6
+ "rootDir": "./src",
7
+ "tsBuildInfoFile": "tsconfig.tsbuildinfo"
8
+ },
9
+ "include": ["src"]
10
+ }