@tsed/apollo 8.0.0-alpha.5 → 8.0.0-alpha.6

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 (40) hide show
  1. package/lib/esm/decorators/injectApolloContext.js.map +1 -1
  2. package/lib/types/interfaces/AlterApolloContext.d.ts +1 -1
  3. package/lib/types/interfaces/AlterApolloServerPlugins.d.ts +1 -1
  4. package/lib/types/interfaces/ApolloSettings.d.ts +2 -2
  5. package/package.json +11 -12
  6. package/lib/cjs/ApolloModule.js +0 -57
  7. package/lib/cjs/ApolloModule.js.map +0 -1
  8. package/lib/cjs/constants/constants.js +0 -6
  9. package/lib/cjs/constants/constants.js.map +0 -1
  10. package/lib/cjs/decorators/dataSource.js +0 -69
  11. package/lib/cjs/decorators/dataSource.js.map +0 -1
  12. package/lib/cjs/decorators/injectApolloContext.js +0 -23
  13. package/lib/cjs/decorators/injectApolloContext.js.map +0 -1
  14. package/lib/cjs/index.js +0 -17
  15. package/lib/cjs/index.js.map +0 -1
  16. package/lib/cjs/interfaces/AlterApolloContext.js +0 -3
  17. package/lib/cjs/interfaces/AlterApolloContext.js.map +0 -1
  18. package/lib/cjs/interfaces/AlterApolloServerPlugins.js +0 -3
  19. package/lib/cjs/interfaces/AlterApolloServerPlugins.js.map +0 -1
  20. package/lib/cjs/interfaces/AlterApolloSettings.js +0 -3
  21. package/lib/cjs/interfaces/AlterApolloSettings.js.map +0 -1
  22. package/lib/cjs/interfaces/ApolloContext.js +0 -3
  23. package/lib/cjs/interfaces/ApolloContext.js.map +0 -1
  24. package/lib/cjs/interfaces/ApolloSettings.js +0 -3
  25. package/lib/cjs/interfaces/ApolloSettings.js.map +0 -1
  26. package/lib/cjs/package.json +0 -3
  27. package/lib/cjs/services/ApolloService.js +0 -189
  28. package/lib/cjs/services/ApolloService.js.map +0 -1
  29. package/lib/esm/package.json +0 -3
  30. package/lib/types-esm/ApolloModule.d.ts +0 -15
  31. package/lib/types-esm/constants/constants.d.ts +0 -2
  32. package/lib/types-esm/decorators/dataSource.d.ts +0 -56
  33. package/lib/types-esm/decorators/injectApolloContext.d.ts +0 -5
  34. package/lib/types-esm/index.d.ts +0 -13
  35. package/lib/types-esm/interfaces/AlterApolloContext.d.ts +0 -5
  36. package/lib/types-esm/interfaces/AlterApolloServerPlugins.d.ts +0 -5
  37. package/lib/types-esm/interfaces/AlterApolloSettings.d.ts +0 -7
  38. package/lib/types-esm/interfaces/ApolloContext.d.ts +0 -4
  39. package/lib/types-esm/interfaces/ApolloSettings.d.ts +0 -32
  40. package/lib/types-esm/services/ApolloService.d.ts +0 -53
@@ -1 +1 @@
1
- {"version":3,"file":"injectApolloContext.js","sourceRoot":"","sources":["../../../src/decorators/injectApolloContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,cAAc,EAAC,MAAM,YAAY,CAAC;AAChF,OAAO,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAEtD;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,CAAC,GAAG,IAAyB,EAAE,EAAE;QACtC,QAAQ,eAAe,CAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,cAAc,CAAC,UAAU;gBAC5B,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;gBAChC,MAAM;YAER,KAAK,cAAc,CAAC,IAAI;gBACtB,OAAO,aAAa,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9E;IACH,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"injectApolloContext.js","sourceRoot":"","sources":["../../../src/decorators/injectApolloContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,cAAc,EAAC,MAAM,YAAY,CAAC;AAChF,OAAO,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAEzD;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,CAAC,GAAG,IAAyB,EAAE,EAAE;QACtC,QAAQ,eAAe,CAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,cAAc,CAAC,UAAU;gBAC5B,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;gBAChC,MAAM;YAER,KAAK,cAAc,CAAC,IAAI;gBACtB,OAAO,aAAa,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9E;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { PlatformContext } from "@tsed/common";
2
- import type { ApolloContext } from "./ApolloContext";
2
+ import type { ApolloContext } from "./ApolloContext.js";
3
3
  export interface AlterApolloContext<Context extends ApolloContext = ApolloContext> {
4
4
  $alterApolloContext(context: Context, $ctx: PlatformContext): Context | Promise<Context>;
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import type { ApolloServerPlugin } from "@apollo/server";
2
- import type { ApolloSettings } from "./ApolloSettings";
2
+ import type { ApolloSettings } from "./ApolloSettings.js";
3
3
  export interface AlterApolloServerPlugins {
4
4
  $alterApolloServerPlugins(plugins: ApolloServerPlugin[], serverSettings: ApolloSettings): ApolloServerPlugin[] | Promise<ApolloServerPlugin[]>;
5
5
  }
@@ -1,8 +1,8 @@
1
1
  import type { ApolloServer, ApolloServerOptions, ApolloServerOptionsWithSchema } from "@apollo/server";
2
2
  import type { GatewayInterface } from "@apollo/server-gateway-interface";
3
3
  import type { IExecutableSchemaDefinition } from "@graphql-tools/schema";
4
- import type { GraphQLSchema } from "graphql/index";
5
- import { ApolloContext } from "./ApolloContext";
4
+ import type { GraphQLSchema } from "graphql/index.js";
5
+ import type { ApolloContext } from "./ApolloContext.js";
6
6
  export type ApolloMiddlewareOptions = Record<string, any>;
7
7
  export type ApolloCustomServerCB<TContext extends ApolloContext> = (config: ApolloServerOptions<TContext>) => ApolloServer<TContext>;
8
8
  declare global {
package/package.json CHANGED
@@ -1,17 +1,16 @@
1
1
  {
2
2
  "name": "@tsed/apollo",
3
3
  "description": "Apollo package for Ts.ED framework",
4
- "type": "commonjs",
5
- "version": "8.0.0-alpha.5",
4
+ "type": "module",
5
+ "version": "8.0.0-alpha.6",
6
6
  "source": "./src/index.ts",
7
- "main": "./lib/cjs/index.js",
7
+ "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
9
9
  "typings": "./lib/types/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
12
  "types": "./lib/types/index.d.ts",
13
13
  "import": "./lib/esm/index.js",
14
- "require": "./lib/cjs/index.js",
15
14
  "default": "./lib/cjs/index.js"
16
15
  }
17
16
  },
@@ -29,12 +28,12 @@
29
28
  "@apollo/datasource-rest": "6.2.2",
30
29
  "@apollo/server": "^4.10.4",
31
30
  "@as-integrations/koa": "1.1.1",
32
- "@tsed/barrels": "8.0.0-alpha.5",
33
- "@tsed/common": "8.0.0-alpha.5",
34
- "@tsed/core": "8.0.0-alpha.5",
35
- "@tsed/di": "8.0.0-alpha.5",
31
+ "@tsed/barrels": "8.0.0-alpha.6",
32
+ "@tsed/common": "8.0.0-alpha.6",
33
+ "@tsed/core": "8.0.0-alpha.6",
34
+ "@tsed/di": "8.0.0-alpha.6",
36
35
  "@tsed/logger": ">=6.7.5",
37
- "@tsed/typescript": "8.0.0-alpha.5",
36
+ "@tsed/typescript": "8.0.0-alpha.6",
38
37
  "apollo-datasource-http": "0.21.0",
39
38
  "apollo-server-testing": "2.25.3",
40
39
  "eslint": "^8.57.0",
@@ -44,9 +43,9 @@
44
43
  },
45
44
  "peerDependencies": {
46
45
  "@apollo/server": ">=4.10.4",
47
- "@tsed/common": "8.0.0-alpha.5",
48
- "@tsed/core": "8.0.0-alpha.5",
49
- "@tsed/di": "8.0.0-alpha.5",
46
+ "@tsed/common": "8.0.0-alpha.6",
47
+ "@tsed/core": "8.0.0-alpha.6",
48
+ "@tsed/di": "8.0.0-alpha.6",
50
49
  "@tsed/logger": ">=6.7.5",
51
50
  "graphql": ">16.0.0"
52
51
  },
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApolloModule = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@tsed/common");
6
- const di_1 = require("@tsed/di");
7
- const ApolloService_js_1 = require("./services/ApolloService.js");
8
- let ApolloModule = class ApolloModule {
9
- get settings() {
10
- return this.configuration.get("apollo", this.configuration.get("graphql", this.configuration.get("typegraphql")));
11
- }
12
- async $onRoutesInit() {
13
- const { settings, injector } = this;
14
- if (settings) {
15
- const promises = Object.entries(settings).map(async ([id, options]) => {
16
- options = await injector.alterAsync("$alterApolloSettings", { id, ...options });
17
- return this.service.createServer(id, options);
18
- });
19
- await Promise.all(promises);
20
- }
21
- }
22
- $afterListen() {
23
- const host = this.configuration.getBestHost();
24
- const displayLog = (key, path) => {
25
- const url = typeof host.port === "number" ? `${host.protocol}://${host.address}:${host.port}` : "";
26
- this.logger.info(`[${key}] Apollo server is available on ${url}/${path.replace(/^\//, "")}`);
27
- };
28
- const { settings } = this;
29
- if (settings) {
30
- Object.entries(settings).map(([key, options]) => {
31
- const { path } = options;
32
- displayLog(key, path);
33
- });
34
- }
35
- }
36
- };
37
- tslib_1.__decorate([
38
- (0, di_1.Inject)(),
39
- tslib_1.__metadata("design:type", common_1.Logger)
40
- ], ApolloModule.prototype, "logger", void 0);
41
- tslib_1.__decorate([
42
- (0, di_1.Inject)(),
43
- tslib_1.__metadata("design:type", ApolloService_js_1.ApolloService)
44
- ], ApolloModule.prototype, "service", void 0);
45
- tslib_1.__decorate([
46
- (0, di_1.Configuration)(),
47
- tslib_1.__metadata("design:type", Object)
48
- ], ApolloModule.prototype, "configuration", void 0);
49
- tslib_1.__decorate([
50
- (0, di_1.Inject)(di_1.InjectorService),
51
- tslib_1.__metadata("design:type", di_1.InjectorService)
52
- ], ApolloModule.prototype, "injector", void 0);
53
- ApolloModule = tslib_1.__decorate([
54
- (0, di_1.Module)()
55
- ], ApolloModule);
56
- exports.ApolloModule = ApolloModule;
57
- //# sourceMappingURL=ApolloModule.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ApolloModule.js","sourceRoot":"","sources":["../../src/ApolloModule.ts"],"names":[],"mappings":";;;;AAAA,yCAA+D;AAC/D,iCAAwE;AAExE,kEAA0D;AAGnD,IAAM,YAAY,GAAlB,MAAM,YAAY;IAavB,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IACpH,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,MAAM,EAAC,QAAQ,EAAE,QAAQ,EAAC,GAAG,IAAI,CAAC;QAElC,IAAI,QAAQ,EAAE;YACZ,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE;gBACpE,OAAO,GAAG,MAAM,QAAQ,CAAC,UAAU,CAAC,sBAAsB,EAAE,EAAC,EAAE,EAAE,GAAG,OAAO,EAAC,CAAC,CAAC;gBAE9E,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;YAChD,CAAC,CAAC,CAAC;YAEH,MAAM,OAA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exports.APOLLO_CONTEXT = exports.DATASOURCES_PROVIDERS = void 0;
4
- exports.DATASOURCES_PROVIDERS = "graphql:datasources";
5
- exports.APOLLO_CONTEXT = Symbol.for("APOLLO_CONTEXT");
6
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG,qBAAqB,CAAC;AAC9C,QAAA,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC"}
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DataSourceService = exports.DataSource = void 0;
4
- const core_1 = require("@tsed/core");
5
- const di_1 = require("@tsed/di");
6
- const constants_js_1 = require("../constants/constants.js");
7
- /**
8
- * Create a new injectable DataSource.
9
- *
10
- * ```typescript
11
- * import { DataSourceService } from "@tsed/graphql";
12
- * import { RESTDataSource } from '@apollo/datasource-rest';
13
- *
14
- * @DataSource()
15
- * export class MyDataSource extends RESTDataSource {
16
- * constructor() {
17
- * super();
18
- * this.baseURL = 'https://awesome-api.example.com';
19
- * }
20
- *
21
- * willSendRequest(request) {
22
- * request.headers.set('Authorization', this.context.token);
23
- * }
24
- *
25
- * getMyData(id: string) {
26
- * return this.get(`/v1/my_rest_data/${id}`);
27
- * }
28
- * }
29
- * ```
30
- *
31
- * @decorator
32
- * @graphql
33
- */
34
- function DataSource(name) {
35
- return (0, core_1.useDecorators)((0, di_1.Injectable)({
36
- type: constants_js_1.DATASOURCES_PROVIDERS,
37
- scope: di_1.ProviderScope.INSTANCE
38
- }), (0, core_1.StoreSet)(constants_js_1.DATASOURCES_PROVIDERS, { name }));
39
- }
40
- exports.DataSource = DataSource;
41
- /**
42
- * Create a new injectable DataSource.
43
- *
44
- * ```typescript
45
- * import { DataSourceService } from "@tsed/graphql";
46
- * import { RESTDataSource } from '@apollo/datasource-rest';
47
- *
48
- * @DataSource()
49
- * export class MyDataSource extends RESTDataSource {
50
- * constructor() {
51
- * super();
52
- * this.baseURL = 'https://awesome-api.example.com';
53
- * }
54
- *
55
- * willSendRequest(request) {
56
- * request.headers.set('Authorization', this.context.token);
57
- * }
58
- *
59
- * getMyData(id: string) {
60
- * return this.get(`/v1/my_rest_data/${id}`);
61
- * }
62
- * }
63
- * ```
64
- *
65
- * @decorator
66
- * @graphql
67
- */
68
- exports.DataSourceService = DataSource;
69
- //# sourceMappingURL=dataSource.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dataSource.js","sourceRoot":"","sources":["../../../src/decorators/dataSource.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,iCAAmD;AACnD,4DAAgE;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,UAAU,CAAC,IAAa;IACtC,OAAO,IAAA,oBAAa,EAClB,IAAA,eAAU,EAAC;QACT,IAAI,EAAE,oCAAqB;QAC3B,KAAK,EAAE,kBAAa,CAAC,QAAQ;KAC9B,CAAC,EACF,IAAA,eAAQ,EAAC,oCAAqB,EAAE,EAAC,IAAI,EAAC,CAAC,CACxC,CAAC;AACJ,CAAC;AARD,gCAQC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACU,QAAA,iBAAiB,GAAG,UAAU,CAAC"}
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InjectApolloContext = void 0;
4
- const core_1 = require("@tsed/core");
5
- const di_1 = require("@tsed/di");
6
- const constants_1 = require("../constants/constants");
7
- /**
8
- * Inject the Apollo context in the decorated property.
9
- * @decorator
10
- */
11
- function InjectApolloContext() {
12
- return (...args) => {
13
- switch ((0, core_1.decoratorTypeOf)(args)) {
14
- case core_1.DecoratorTypes.PARAM_CTOR:
15
- (0, di_1.Inject)(constants_1.APOLLO_CONTEXT)(...args);
16
- break;
17
- case core_1.DecoratorTypes.PROP:
18
- return (0, di_1.InjectContext)(($ctx) => $ctx.get(constants_1.APOLLO_CONTEXT))(args[0], args[1]);
19
- }
20
- };
21
- }
22
- exports.InjectApolloContext = InjectApolloContext;
23
- //# sourceMappingURL=injectApolloContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectApolloContext.js","sourceRoot":"","sources":["../../../src/decorators/injectApolloContext.ts"],"names":[],"mappings":";;;AAAA,qCAAgF;AAChF,iCAA+C;AAC/C,sDAAsD;AAEtD;;;GAGG;AACH,SAAgB,mBAAmB;IACjC,OAAO,CAAC,GAAG,IAAyB,EAAE,EAAE;QACtC,QAAQ,IAAA,sBAAe,EAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,qBAAc,CAAC,UAAU;gBAC5B,IAAA,WAAM,EAAC,0BAAc,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;gBAChC,MAAM;YAER,KAAK,qBAAc,CAAC,IAAI;gBACtB,OAAO,IAAA,kBAAa,EAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,0BAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9E;IACH,CAAC,CAAC;AACJ,CAAC;AAXD,kDAWC"}
package/lib/cjs/index.js DELETED
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- /**
5
- * @file Automatically generated by @tsed/barrels.
6
- */
7
- tslib_1.__exportStar(require("./ApolloModule.js"), exports);
8
- tslib_1.__exportStar(require("./constants/constants.js"), exports);
9
- tslib_1.__exportStar(require("./decorators/dataSource.js"), exports);
10
- tslib_1.__exportStar(require("./decorators/injectApolloContext.js"), exports);
11
- tslib_1.__exportStar(require("./interfaces/AlterApolloContext.js"), exports);
12
- tslib_1.__exportStar(require("./interfaces/AlterApolloServerPlugins.js"), exports);
13
- tslib_1.__exportStar(require("./interfaces/AlterApolloSettings.js"), exports);
14
- tslib_1.__exportStar(require("./interfaces/ApolloContext.js"), exports);
15
- tslib_1.__exportStar(require("./interfaces/ApolloSettings.js"), exports);
16
- tslib_1.__exportStar(require("./services/ApolloService.js"), exports);
17
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,4DAAkC;AAClC,mEAAyC;AACzC,qEAA2C;AAC3C,8EAAoD;AACpD,6EAAmD;AACnD,mFAAyD;AACzD,8EAAoD;AACpD,wEAA8C;AAC9C,yEAA+C;AAC/C,sEAA4C"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=AlterApolloContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AlterApolloContext.js","sourceRoot":"","sources":["../../../src/interfaces/AlterApolloContext.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=AlterApolloServerPlugins.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AlterApolloServerPlugins.js","sourceRoot":"","sources":["../../../src/interfaces/AlterApolloServerPlugins.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=AlterApolloSettings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AlterApolloSettings.js","sourceRoot":"","sources":["../../../src/interfaces/AlterApolloSettings.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=ApolloContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ApolloContext.js","sourceRoot":"","sources":["../../../src/interfaces/ApolloContext.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=ApolloSettings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ApolloSettings.js","sourceRoot":"","sources":["../../../src/interfaces/ApolloSettings.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1,189 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApolloService = void 0;
4
- const tslib_1 = require("tslib");
5
- const server_1 = require("@apollo/server");
6
- const disabled_1 = require("@apollo/server/plugin/disabled");
7
- const drainHttpServer_1 = require("@apollo/server/plugin/drainHttpServer");
8
- const default_1 = require("@apollo/server/plugin/landingPage/default");
9
- const common_1 = require("@tsed/common");
10
- const di_1 = require("@tsed/di");
11
- const logger_1 = require("@tsed/logger");
12
- const http_1 = tslib_1.__importDefault(require("http"));
13
- const https_1 = tslib_1.__importDefault(require("https"));
14
- const constants_js_1 = require("../constants/constants.js");
15
- let ApolloService = class ApolloService {
16
- constructor() {
17
- /**
18
- *
19
- * @type {Map<any, any>}
20
- * @private
21
- */
22
- this.servers = new Map();
23
- }
24
- async createServer(id, settings) {
25
- if (!this.has(id)) {
26
- try {
27
- const { dataSources, path, middlewareOptions = {}, server: customServer, ...config } = settings;
28
- this.logger.info(`Create server with Apollo for: ${id}`);
29
- this.logger.debug(`options: ${JSON.stringify({ path })}`);
30
- const plugins = await this.getPlugins(settings);
31
- const server = this.createInstance({
32
- ...config,
33
- plugins
34
- }, customServer);
35
- if (server) {
36
- this.servers.set(id || "default", {
37
- instance: server,
38
- schema: settings.schema,
39
- typeDefs: settings.typeDefs,
40
- resolvers: settings.resolvers
41
- });
42
- await server.start();
43
- const contextHandler = this.createContextHandler(server, settings);
44
- switch (this.platformName) {
45
- case "express":
46
- const { expressMiddleware } = await import("@apollo/server/express4");
47
- this.app.use(path, expressMiddleware(server, {
48
- ...middlewareOptions,
49
- context: contextHandler
50
- }));
51
- break;
52
- case "koa":
53
- const { koaMiddleware } = await import("@as-integrations/koa");
54
- this.app.use(path, koaMiddleware(server, {
55
- ...middlewareOptions,
56
- context: contextHandler
57
- }));
58
- break;
59
- default:
60
- this.logger.warn({
61
- event: "APOLLO_UNKNOWN_PLATFORM",
62
- message: "Platform not supported. Please use Ts.ED platform (express, koa)"
63
- });
64
- }
65
- }
66
- }
67
- catch (er) {
68
- this.logger.error({
69
- event: "APOLLO_BOOTSTRAP_ERROR",
70
- error_name: er.name,
71
- message: er.message,
72
- stack: er.stack
73
- });
74
- throw er;
75
- }
76
- }
77
- return this.get(id);
78
- }
79
- /**
80
- * Get an instance of ApolloServer from his id
81
- * @returns ApolloServer
82
- */
83
- get(id = "default") {
84
- return this.servers.get(id)?.instance;
85
- }
86
- /**
87
- * Get schema of the ApolloServer from his id
88
- * @returns GraphQLSchema
89
- */
90
- getSchema(id = "default") {
91
- return this.servers.get(id)?.schema;
92
- }
93
- /**
94
- * Get TypeDefs of the ApolloServer from his id
95
- */
96
- getTypeDefs(id = "default") {
97
- return this.servers.get(id)?.typeDefs;
98
- }
99
- getResolvers(id = "default") {
100
- return this.servers.get(id)?.resolvers;
101
- }
102
- /**
103
- *
104
- * @param {string} id
105
- * @returns {boolean}
106
- */
107
- has(id = "default") {
108
- return this.servers.has(id);
109
- }
110
- /**
111
- * create a new dataSources function to use with apollo server config
112
- */
113
- createContextHandler(server, settings) {
114
- const { injector } = this;
115
- const dataSourcesContainer = injector.getProviders(constants_js_1.DATASOURCES_PROVIDERS).reduce((map, provider) => {
116
- let { name } = provider.store.get(constants_js_1.DATASOURCES_PROVIDERS);
117
- name = name || provider.className;
118
- const sourceName = `${name[0].toLowerCase()}${name.slice(1)}`;
119
- map.set(sourceName, provider);
120
- return map;
121
- }, new Map());
122
- return async () => {
123
- const $ctx = (0, common_1.useContext)();
124
- const context = {
125
- dataSources: {
126
- ...(settings.dataSources?.() || {})
127
- }
128
- };
129
- const alteredContext = await this.injector.alterAsync("$alterApolloContext", context, $ctx);
130
- $ctx.set(constants_js_1.APOLLO_CONTEXT, alteredContext);
131
- const locals = new common_1.LocalsContainer();
132
- locals.set(constants_js_1.APOLLO_CONTEXT, alteredContext);
133
- locals.set(server_1.ApolloServer, server);
134
- dataSourcesContainer.forEach((provider, key) => {
135
- alteredContext.dataSources[key] = injector.invoke(provider.token, locals);
136
- });
137
- return alteredContext;
138
- };
139
- }
140
- createInstance(options, server) {
141
- return server ? server(options) : new server_1.ApolloServer(options);
142
- }
143
- async getPlugins(serverSettings) {
144
- const playground = serverSettings.playground || (serverSettings.playground === undefined && process.env.NODE_ENV !== "production");
145
- const result = await this.injector.alterAsync("$alterApolloServerPlugins", [
146
- this.httpServer &&
147
- (0, drainHttpServer_1.ApolloServerPluginDrainHttpServer)({
148
- httpServer: this.httpServer
149
- }),
150
- this.httpsServer &&
151
- (0, drainHttpServer_1.ApolloServerPluginDrainHttpServer)({
152
- httpServer: this.httpsServer
153
- }),
154
- ...(serverSettings.plugins || [])
155
- ].filter(Boolean), serverSettings);
156
- return result
157
- .concat([playground ? (0, default_1.ApolloServerPluginLandingPageLocalDefault)({ embed: true }) : (0, disabled_1.ApolloServerPluginLandingPageDisabled)()])
158
- .filter(Boolean);
159
- }
160
- };
161
- tslib_1.__decorate([
162
- (0, di_1.Constant)("PLATFORM_NAME"),
163
- tslib_1.__metadata("design:type", String)
164
- ], ApolloService.prototype, "platformName", void 0);
165
- tslib_1.__decorate([
166
- (0, di_1.Inject)(),
167
- tslib_1.__metadata("design:type", logger_1.Logger)
168
- ], ApolloService.prototype, "logger", void 0);
169
- tslib_1.__decorate([
170
- (0, di_1.Inject)(),
171
- tslib_1.__metadata("design:type", common_1.PlatformApplication)
172
- ], ApolloService.prototype, "app", void 0);
173
- tslib_1.__decorate([
174
- (0, di_1.Inject)(http_1.default.Server),
175
- tslib_1.__metadata("design:type", Object)
176
- ], ApolloService.prototype, "httpServer", void 0);
177
- tslib_1.__decorate([
178
- (0, di_1.Inject)(https_1.default.Server),
179
- tslib_1.__metadata("design:type", Object)
180
- ], ApolloService.prototype, "httpsServer", void 0);
181
- tslib_1.__decorate([
182
- (0, di_1.Inject)(),
183
- tslib_1.__metadata("design:type", common_1.InjectorService)
184
- ], ApolloService.prototype, "injector", void 0);
185
- ApolloService = tslib_1.__decorate([
186
- (0, di_1.Service)()
187
- ], ApolloService);
188
- exports.ApolloService = ApolloService;
189
- //# sourceMappingURL=ApolloService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ApolloService.js","sourceRoot":"","sources":["../../../src/services/ApolloService.ts"],"names":[],"mappings":";;;;AAAA,2CAAqF;AACrF,6DAAqF;AACrF,2EAAwF;AACxF,uEAAoG;AAEpG,yCAA0H;AAC1H,iCAAmD;AACnD,yCAAoC;AAEpC,wDAAwB;AACxB,0DAA0B;AAC1B,4DAAgF;AAKzE,IAAM,aAAa,GAAnB,MAAM,aAAa;IAAnB;QAOL;;;;WAIG;QACO,YAAO,GAQb,IAAI,GAAG,EAAE,CAAC;IAgMhB,CAAC;IAlLC,KAAK,CAAC,YAAY,CAAC,EAAU,EAAE,QAAwB;QACrD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YACjB,IAAI;gBACF,MAAM,EAAC,WAAW,EAAE,IAAI,EAAE,iBAAiB,GAAG,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,EAAC,GAAG,QAAQ,CAAC;gBAE9F,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE,EAAE,CAAC,CAAC;gBACzD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,EAAC,IAAI,EAAC,CAAC,EAAE,CAAC,CAAC;gBAExD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;gBAEhD,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAChC;o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GACG,aAAa,CAoNzB;AApNY,sCAAa"}
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
@@ -1,15 +0,0 @@
1
- import { AfterListen, Logger, OnRoutesInit } from "@tsed/common";
2
- import { Configuration, InjectorService } from "@tsed/di";
3
- import { ApolloSettings } from "./interfaces/ApolloSettings.js";
4
- import { ApolloService } from "./services/ApolloService.js";
5
- export declare class ApolloModule implements OnRoutesInit, AfterListen {
6
- protected logger: Logger;
7
- protected service: ApolloService;
8
- protected configuration: Configuration;
9
- protected injector: InjectorService;
10
- get settings(): {
11
- [key: string]: ApolloSettings;
12
- } | undefined;
13
- $onRoutesInit(): Promise<void>;
14
- $afterListen(): Promise<any> | void;
15
- }
@@ -1,2 +0,0 @@
1
- export declare const DATASOURCES_PROVIDERS = "graphql:datasources";
2
- export declare const APOLLO_CONTEXT: unique symbol;
@@ -1,56 +0,0 @@
1
- /**
2
- * Create a new injectable DataSource.
3
- *
4
- * ```typescript
5
- * import { DataSourceService } from "@tsed/graphql";
6
- * import { RESTDataSource } from '@apollo/datasource-rest';
7
- *
8
- * @DataSource()
9
- * export class MyDataSource extends RESTDataSource {
10
- * constructor() {
11
- * super();
12
- * this.baseURL = 'https://awesome-api.example.com';
13
- * }
14
- *
15
- * willSendRequest(request) {
16
- * request.headers.set('Authorization', this.context.token);
17
- * }
18
- *
19
- * getMyData(id: string) {
20
- * return this.get(`/v1/my_rest_data/${id}`);
21
- * }
22
- * }
23
- * ```
24
- *
25
- * @decorator
26
- * @graphql
27
- */
28
- export declare function DataSource(name?: string): ClassDecorator;
29
- /**
30
- * Create a new injectable DataSource.
31
- *
32
- * ```typescript
33
- * import { DataSourceService } from "@tsed/graphql";
34
- * import { RESTDataSource } from '@apollo/datasource-rest';
35
- *
36
- * @DataSource()
37
- * export class MyDataSource extends RESTDataSource {
38
- * constructor() {
39
- * super();
40
- * this.baseURL = 'https://awesome-api.example.com';
41
- * }
42
- *
43
- * willSendRequest(request) {
44
- * request.headers.set('Authorization', this.context.token);
45
- * }
46
- *
47
- * getMyData(id: string) {
48
- * return this.get(`/v1/my_rest_data/${id}`);
49
- * }
50
- * }
51
- * ```
52
- *
53
- * @decorator
54
- * @graphql
55
- */
56
- export declare const DataSourceService: typeof DataSource;
@@ -1,5 +0,0 @@
1
- /**
2
- * Inject the Apollo context in the decorated property.
3
- * @decorator
4
- */
5
- export declare function InjectApolloContext(): any;
@@ -1,13 +0,0 @@
1
- /**
2
- * @file Automatically generated by @tsed/barrels.
3
- */
4
- export * from "./ApolloModule.js";
5
- export * from "./constants/constants.js";
6
- export * from "./decorators/dataSource.js";
7
- export * from "./decorators/injectApolloContext.js";
8
- export * from "./interfaces/AlterApolloContext.js";
9
- export * from "./interfaces/AlterApolloServerPlugins.js";
10
- export * from "./interfaces/AlterApolloSettings.js";
11
- export * from "./interfaces/ApolloContext.js";
12
- export * from "./interfaces/ApolloSettings.js";
13
- export * from "./services/ApolloService.js";
@@ -1,5 +0,0 @@
1
- import type { PlatformContext } from "@tsed/common";
2
- import type { ApolloContext } from "./ApolloContext";
3
- export interface AlterApolloContext<Context extends ApolloContext = ApolloContext> {
4
- $alterApolloContext(context: Context, $ctx: PlatformContext): Context | Promise<Context>;
5
- }
@@ -1,5 +0,0 @@
1
- import type { ApolloServerPlugin } from "@apollo/server";
2
- import type { ApolloSettings } from "./ApolloSettings";
3
- export interface AlterApolloServerPlugins {
4
- $alterApolloServerPlugins(plugins: ApolloServerPlugin[], serverSettings: ApolloSettings): ApolloServerPlugin[] | Promise<ApolloServerPlugin[]>;
5
- }
@@ -1,7 +0,0 @@
1
- import type { ApolloContext } from "./ApolloContext.js";
2
- import type { ApolloSettingsWithID } from "./ApolloSettings.js";
3
- export interface AlterApolloSettings<Context extends ApolloContext = ApolloContext> {
4
- $alterApolloSettings(settings: ApolloSettingsWithID<Context>): (ApolloSettingsWithID<Context> & {
5
- id: string;
6
- }) | Promise<ApolloSettingsWithID<Context>>;
7
- }
@@ -1,4 +0,0 @@
1
- import type { BaseContext } from "@apollo/server";
2
- export interface ApolloContext extends BaseContext {
3
- dataSources: Record<string, unknown>;
4
- }
@@ -1,32 +0,0 @@
1
- import type { ApolloServer, ApolloServerOptions, ApolloServerOptionsWithSchema } from "@apollo/server";
2
- import type { GatewayInterface } from "@apollo/server-gateway-interface";
3
- import type { IExecutableSchemaDefinition } from "@graphql-tools/schema";
4
- import type { GraphQLSchema } from "graphql/index";
5
- import { ApolloContext } from "./ApolloContext";
6
- export type ApolloMiddlewareOptions = Record<string, any>;
7
- export type ApolloCustomServerCB<TContext extends ApolloContext> = (config: ApolloServerOptions<TContext>) => ApolloServer<TContext>;
8
- declare global {
9
- namespace TsED {
10
- interface ApolloSettings {
11
- }
12
- }
13
- }
14
- export type ApolloServerOptionsBase<TContext extends ApolloContext = ApolloContext> = Omit<ApolloServerOptionsWithSchema<TContext>, "schema" | "typeDefs" | "resolvers" | "gateway">;
15
- export type ApolloSettings<TContext extends ApolloContext = ApolloContext> = ApolloServerOptionsBase<TContext> & TsED.ApolloSettings & {
16
- path: string;
17
- server?: ApolloCustomServerCB<TContext>;
18
- playground?: boolean;
19
- serverRegistration?: ApolloMiddlewareOptions;
20
- middlewareOptions?: ApolloMiddlewareOptions;
21
- schema?: GraphQLSchema;
22
- typeDefs?: IExecutableSchemaDefinition<TContext>["typeDefs"];
23
- resolvers?: IExecutableSchemaDefinition<TContext>["resolvers"];
24
- gateway?: GatewayInterface;
25
- /**
26
- * @deprecated use $alterApolloContext instead
27
- */
28
- dataSources?: () => Record<string, unknown>;
29
- };
30
- export type ApolloSettingsWithID<TContext extends ApolloContext = ApolloContext> = ApolloSettings<TContext> & {
31
- id: string;
32
- };
@@ -1,53 +0,0 @@
1
- import { ApolloServer, ApolloServerOptions } from "@apollo/server";
2
- import type { IExecutableSchemaDefinition } from "@graphql-tools/schema";
3
- import { Logger } from "@tsed/logger";
4
- import type { GraphQLSchema } from "graphql";
5
- import { ApolloContext } from "../interfaces/ApolloContext.js";
6
- import type { ApolloCustomServerCB, ApolloSettings } from "../interfaces/ApolloSettings.js";
7
- export declare class ApolloService {
8
- platformName: string;
9
- protected logger: Logger;
10
- /**
11
- *
12
- * @type {Map<any, any>}
13
- * @private
14
- */
15
- protected servers: Map<string, {
16
- instance: ApolloServer<ApolloContext>;
17
- schema?: GraphQLSchema;
18
- typeDefs?: IExecutableSchemaDefinition<ApolloContext>["typeDefs"];
19
- resolvers?: IExecutableSchemaDefinition<ApolloContext>["resolvers"];
20
- }>;
21
- private app;
22
- private httpServer;
23
- private httpsServer;
24
- private injector;
25
- createServer(id: string, settings: ApolloSettings): Promise<ApolloServer<ApolloContext>>;
26
- /**
27
- * Get an instance of ApolloServer from his id
28
- * @returns ApolloServer
29
- */
30
- get(id?: string): ApolloServer<ApolloContext> | undefined;
31
- /**
32
- * Get schema of the ApolloServer from his id
33
- * @returns GraphQLSchema
34
- */
35
- getSchema(id?: string): GraphQLSchema | undefined;
36
- /**
37
- * Get TypeDefs of the ApolloServer from his id
38
- */
39
- getTypeDefs(id?: string): import("@graphql-tools/utils").TypeSource | undefined;
40
- getResolvers(id?: string): import("@graphql-tools/utils").IResolvers<any, ApolloContext, Record<string, any>, any> | import("@graphql-tools/utils").IResolvers<any, ApolloContext, Record<string, any>, any>[] | undefined;
41
- /**
42
- *
43
- * @param {string} id
44
- * @returns {boolean}
45
- */
46
- has(id?: string): boolean;
47
- /**
48
- * create a new dataSources function to use with apollo server config
49
- */
50
- createContextHandler(server: ApolloServer<ApolloContext>, settings: ApolloSettings): () => Promise<any>;
51
- protected createInstance(options: ApolloServerOptions<ApolloContext>, server?: ApolloCustomServerCB<ApolloContext>): ApolloServer<ApolloContext>;
52
- private getPlugins;
53
- }