@tsed/apollo 6.75.5 → 6.75.9

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.
@@ -19,12 +19,16 @@ let ApolloModule = class ApolloModule {
19
19
  }
20
20
  }
21
21
  $afterListen() {
22
+ const host = this.configuration.getBestHost();
23
+ const displayLog = (key, path) => {
24
+ const url = typeof host.port === "number" ? `${host.protocol}://${host.address}:${host.port}` : "";
25
+ this.logger.info(`[${key}] Apollo server is available on ${url}${path.replace(/^\//, "")}`);
26
+ };
22
27
  const { settings } = this;
23
28
  if (settings) {
24
- const host = this.configuration.getHttpPort();
25
29
  Object.entries(settings).map(async ([key, options]) => {
26
30
  const { path } = options;
27
- this.logger.info(`[${key}] Apollo server is available on http://${host.address}:${host.port}/${path.replace(/^\//, "")}`);
31
+ displayLog(key, path);
28
32
  });
29
33
  }
30
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ApolloModule.js","sourceRoot":"","sources":["../src/ApolloModule.ts"],"names":[],"mappings":";;;;AAAA,yCAA6G;AAC7G,iCAAiE;AAEjE,4DAAuD;AAGvD,IAAa,YAAY,GAAzB,MAAa,YAAY;IAUvB,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAED,aAAa;QACX,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QAExB,IAAI,QAAQ,EAAE;YACZ,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE;gBACrE,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACjD,CAAC,CAAC,CAAC;YAEH,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;SAC9B;IACH,CAAC;IAED,YAAY;QACV,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QAExB,IAAI,QAAQ,EAAE;YACZ,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;YAE9C,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE;gBACpD,MAAM,EAAC,IAAI,EAAC,GAAG,OAAO,CAAC;gBACvB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,0CAA0C,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;YAC5H,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;CACF,CAAA;AApCC;IADC,WAAM,EAAE;sCACS,eAAM;4CAAC;AAGzB;IADC,WAAM,EAAE;sCACU,6BAAa;6CAAC;AAGjC;IADC,kBAAa,EAAE;;mDACuB;AAR5B,YAAY;IADxB,WAAM,EAAE;GACI,YAAY,CAsCxB;AAtCY,oCAAY","sourcesContent":["import {AfterListen, HttpServer, HttpsServer, Logger, OnRoutesInit, PlatformApplication} from \"@tsed/common\";\nimport {Configuration, Constant, Inject, Module} from \"@tsed/di\";\nimport {ApolloServer, ApolloSettings} from \"./interfaces/ApolloSettings\";\nimport {ApolloService} from \"./services/ApolloService\";\n\n@Module()\nexport class ApolloModule implements OnRoutesInit, AfterListen {\n @Inject()\n protected logger: Logger;\n\n @Inject()\n protected service: ApolloService;\n\n @Configuration()\n protected configuration: Configuration;\n\n get settings(): {[key: string]: ApolloSettings} | undefined {\n return this.configuration.get(\"apollo\");\n }\n\n $onRoutesInit(): Promise<any> | void {\n const {settings} = this;\n\n if (settings) {\n const promises = Object.entries(settings).map(async ([key, options]) => {\n return this.service.createServer(key, options);\n });\n\n return Promise.all(promises);\n }\n }\n\n $afterListen(): Promise<any> | void {\n const {settings} = this;\n\n if (settings) {\n const host = this.configuration.getHttpPort();\n\n Object.entries(settings).map(async ([key, options]) => {\n const {path} = options;\n this.logger.info(`[${key}] Apollo server is available on http://${host.address}:${host.port}/${path.replace(/^\\//, \"\")}`);\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ApolloModule.js","sourceRoot":"","sources":["../src/ApolloModule.ts"],"names":[],"mappings":";;;;AAAA,yCAA+D;AAC/D,iCAAuD;AAEvD,4DAAuD;AAGvD,IAAa,YAAY,GAAzB,MAAa,YAAY;IAUvB,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAED,aAAa;QACX,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QAExB,IAAI,QAAQ,EAAE;YACZ,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE;gBACrE,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACjD,CAAC,CAAC,CAAC;YAEH,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;SAC9B;IACH,CAAC;IAED,YAAY;QACV,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;QAE9C,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,IAAY,EAAE,EAAE;YAC/C,MAAM,GAAG,GAAG,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,MAAM,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAEnG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,mCAAmC,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;QAC9F,CAAC,CAAC;QAEF,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QAExB,IAAI,QAAQ,EAAE;YACZ,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE;gBACpD,MAAM,EAAC,IAAI,EAAC,GAAG,OAAO,CAAC;gBAEvB,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YACxB,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;CACF,CAAA;AA3CC;IADC,WAAM,EAAE;sCACS,eAAM;4CAAC;AAGzB;IADC,WAAM,EAAE;sCACU,6BAAa;6CAAC;AAGjC;IADC,kBAAa,EAAE;;mDACuB;AAR5B,YAAY;IADxB,WAAM,EAAE;GACI,YAAY,CA6CxB;AA7CY,oCAAY","sourcesContent":["import {AfterListen, Logger, OnRoutesInit} from \"@tsed/common\";\nimport {Configuration, Inject, Module} from \"@tsed/di\";\nimport {ApolloSettings} from \"./interfaces/ApolloSettings\";\nimport {ApolloService} from \"./services/ApolloService\";\n\n@Module()\nexport class ApolloModule implements OnRoutesInit, AfterListen {\n @Inject()\n protected logger: Logger;\n\n @Inject()\n protected service: ApolloService;\n\n @Configuration()\n protected configuration: Configuration;\n\n get settings(): {[key: string]: ApolloSettings} | undefined {\n return this.configuration.get(\"apollo\");\n }\n\n $onRoutesInit(): Promise<any> | void {\n const {settings} = this;\n\n if (settings) {\n const promises = Object.entries(settings).map(async ([key, options]) => {\n return this.service.createServer(key, options);\n });\n\n return Promise.all(promises);\n }\n }\n\n $afterListen(): Promise<any> | void {\n const host = this.configuration.getBestHost();\n\n const displayLog = (key: string, path: string) => {\n const url = typeof host.port === \"number\" ? `${host.protocol}://${host.address}:${host.port}` : \"\";\n\n this.logger.info(`[${key}] Apollo server is available on ${url}${path.replace(/^\\//, \"\")}`);\n };\n\n const {settings} = this;\n\n if (settings) {\n Object.entries(settings).map(async ([key, options]) => {\n const {path} = options;\n\n displayLog(key, path);\n });\n }\n }\n}\n"]}
@@ -3,7 +3,6 @@ import type { Config } from "apollo-server-core";
3
3
  import type { GraphQLSchema } from "graphql";
4
4
  import type { ApolloServer, ApolloSettings } from "../interfaces/ApolloSettings";
5
5
  export declare class ApolloService {
6
- #private;
7
6
  platformName: string;
8
7
  private httpPort;
9
8
  private httpsPort;
@@ -11,6 +10,15 @@ export declare class ApolloService {
11
10
  private httpServer;
12
11
  private httpsServer;
13
12
  protected logger: Logger;
13
+ /**
14
+ *
15
+ * @type {Map<any, any>}
16
+ * @private
17
+ */
18
+ protected servers: Map<string, {
19
+ instance: ApolloServer;
20
+ schema: GraphQLSchema | undefined;
21
+ }>;
14
22
  createServer(id: string, settings: ApolloSettings): Promise<any>;
15
23
  /**
16
24
  * Get an instance of ApolloServer from his id
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- var _servers;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.ApolloService = void 0;
5
4
  const tslib_1 = require("tslib");
@@ -11,7 +10,7 @@ let ApolloService = class ApolloService {
11
10
  * @type {Map<any, any>}
12
11
  * @private
13
12
  */
14
- _servers.set(this, new Map());
13
+ this.servers = new Map();
15
14
  }
16
15
  async createServer(id, settings) {
17
16
  if (this.has(id)) {
@@ -23,7 +22,7 @@ let ApolloService = class ApolloService {
23
22
  this.logger.debug(`options: ${JSON.stringify({ path })}`);
24
23
  const server = this.createInstance(serverSettings, customServer);
25
24
  if (server) {
26
- tslib_1.__classPrivateFieldGet(this, _servers).set(id || "default", {
25
+ this.servers.set(id || "default", {
27
26
  instance: server,
28
27
  schema: settings.schema
29
28
  });
@@ -43,7 +42,7 @@ let ApolloService = class ApolloService {
43
42
  */
44
43
  get(id = "default") {
45
44
  var _a;
46
- return (_a = tslib_1.__classPrivateFieldGet(this, _servers).get(id)) === null || _a === void 0 ? void 0 : _a.instance;
45
+ return (_a = this.servers.get(id)) === null || _a === void 0 ? void 0 : _a.instance;
47
46
  }
48
47
  /**
49
48
  * Get an instance of GraphQL schema from his id
@@ -51,7 +50,7 @@ let ApolloService = class ApolloService {
51
50
  */
52
51
  getSchema(id = "default") {
53
52
  var _a;
54
- return (_a = tslib_1.__classPrivateFieldGet(this, _servers).get(id)) === null || _a === void 0 ? void 0 : _a.schema;
53
+ return (_a = this.servers.get(id)) === null || _a === void 0 ? void 0 : _a.schema;
55
54
  }
56
55
  /**
57
56
  *
@@ -59,7 +58,7 @@ let ApolloService = class ApolloService {
59
58
  * @returns {boolean}
60
59
  */
61
60
  has(id = "default") {
62
- return tslib_1.__classPrivateFieldGet(this, _servers).has(id);
61
+ return this.servers.has(id);
63
62
  }
64
63
  async bindServer(server, options) {
65
64
  await server.applyMiddleware({ path: options.path, ...options.serverRegistration, app: this.app.raw });
@@ -84,7 +83,6 @@ let ApolloService = class ApolloService {
84
83
  }
85
84
  }
86
85
  };
87
- _servers = new WeakMap();
88
86
  tslib_1.__decorate([
89
87
  common_1.Constant("PLATFORM_NAME"),
90
88
  tslib_1.__metadata("design:type", String)
@@ -1 +1 @@
1
- {"version":3,"file":"ApolloService.js","sourceRoot":"","sources":["../../src/services/ApolloService.ts"],"names":[],"mappings":";;;;;AAAA,yCAA6G;AAM7G,IAAa,aAAa,GAA1B,MAAa,aAAa;IAA1B;QAsBE;;;;WAIG;QACH,mBAMI,IAAI,GAAG,EAAE,EAAC;IAkFhB,CAAC;IAhFC,KAAK,CAAC,YAAY,CAAC,EAAU,EAAE,QAAwB;QACrD,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YAChB,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAE,CAAC;SACtB;QAED,IAAI;YACF,MAAM,EAAC,IAAI,EAAE,2BAA2B,EAAE,kBAAkB,GAAG,EAAE,EAAE,MAAM,EAAE,YAAY,E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["import {Constant, HttpServer, HttpsServer, Inject, Logger, PlatformApplication, Service} from \"@tsed/common\";\nimport type {Config} from \"apollo-server-core\";\nimport type {GraphQLSchema} from \"graphql\";\nimport type {ApolloServer, ApolloSettings} from \"../interfaces/ApolloSettings\";\n\n@Service()\nexport class ApolloService {\n @Constant(\"PLATFORM_NAME\")\n platformName: string;\n\n @Constant(\"httpPort\")\n private httpPort: string | number;\n\n @Constant(\"httpsPort\")\n private httpsPort: string | number;\n\n @Inject()\n private app: PlatformApplication;\n\n @Inject(HttpServer)\n private httpServer: HttpServer;\n\n @Inject(HttpsServer)\n private httpsServer: HttpsServer;\n\n @Inject()\n protected logger: Logger;\n\n /**\n *\n * @type {Map<any, any>}\n * @private\n */\n #servers: Map<\n string,\n {\n instance: ApolloServer;\n schema: GraphQLSchema | undefined;\n }\n > = new Map();\n\n async createServer(id: string, settings: ApolloSettings): Promise<any> {\n if (this.has(id)) {\n return this.get(id)!;\n }\n\n try {\n const {path, installSubscriptionHandlers, serverRegistration = {}, server: customServer, ...serverSettings} = settings;\n\n this.logger.info(`Create server with Apollo for: ${id}`);\n this.logger.debug(`options: ${JSON.stringify({path})}`);\n\n const server = this.createInstance(serverSettings, customServer);\n\n if (server) {\n this.#servers.set(id || \"default\", {\n instance: server,\n schema: settings.schema\n });\n\n return this.bindServer(server, settings);\n }\n } catch (err) {\n /* istanbul ignore next */\n this.logger.error(err);\n /* istanbul ignore next */\n process.exit(-1);\n }\n }\n\n /**\n * Get an instance of ApolloServer from his id\n * @returns ApolloServer\n */\n get(id: string = \"default\"): ApolloServer | undefined {\n return this.#servers.get(id)?.instance;\n }\n\n /**\n * Get an instance of GraphQL schema from his id\n * @returns GraphQLSchema\n */\n getSchema(id: string = \"default\"): GraphQLSchema | undefined {\n return this.#servers.get(id)?.schema;\n }\n\n /**\n *\n * @param {string} id\n * @returns {boolean}\n */\n has(id: string = \"default\"): boolean {\n return this.#servers.has(id);\n }\n\n protected async bindServer(server: ApolloServer, options: ApolloSettings) {\n await server.applyMiddleware({path: options.path, ...options.serverRegistration, app: this.app.raw});\n\n if (options.installSubscriptionHandlers && (this.httpPort || this.httpsPort)) {\n this.httpPort && server.installSubscriptionHandlers(this.httpServer);\n this.httpPort && server.installSubscriptionHandlers(this.httpsServer);\n }\n\n return server;\n }\n\n protected createInstance(options: Config, server?: (config: Config) => ApolloServer): ApolloServer | undefined {\n // istanbul ignore next\n if (server) {\n return server(options);\n }\n\n // istanbul ignore next\n try {\n const Server = require(`apollo-server-${this.platformName || \"express\"}`).ApolloServer;\n\n return new Server(options);\n } catch (er) {\n this.logger.error(`Platform \"${this.platformName}\" not supported by @tsed/apollo`);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ApolloService.js","sourceRoot":"","sources":["../../src/services/ApolloService.ts"],"names":[],"mappings":";;;;AAAA,yCAA6G;AAM7G,IAAa,aAAa,GAA1B,MAAa,aAAa;IAA1B;QAsBE;;;;WAIG;QACO,YAAO,GAMb,IAAI,GAAG,EAAE,CAAC;IAkFhB,CAAC;IAhFC,KAAK,CAAC,YAAY,CAAC,EAAU,EAAE,QAAwB;QACrD,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YAChB,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAE,CAAC;SACtB;QAED,IAAI;YACF,MAAM,EAAC,IAAI,EAAE,2BAA2B,EAAE,kBAAkB,GAAG,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,cAAc,EAAC,GAAG,QAAQ,CAAC;YAEvH,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE,EAAE,CAAC,CAAC;YACzD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,EAAC,IAAI,EAAC,CAAC,EAAE,CAAC,CAAC;YAExD,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;YAEjE,IAAI,MAAM,EAA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AC;YACrE,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,2BAA2B,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SACvE;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAES,cAAc,CAAC,OAAe,EAAE,MAAyC;QACjF,uBAAuB;QACvB,IAAI,MAAM,EAAE;YACV,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;SACxB;QAED,uBAAuB;QACvB,IAAI;YACF,MAAM,MAAM,GAAG,OAAO,CAAC,iBAAiB,IAAI,CAAC,YAAY,IAAI,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC;YAEvF,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;SAC5B;QAAC,OAAO,EAAE,EAAE;YACX,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,YAAY,iCAAiC,CAAC,CAAC;SACpF;IACH,CAAC;CACF,CAAA;AAjHC;IADC,iBAAQ,CAAC,eAAe,CAAC;;mDACL;AAGrB;IADC,iBAAQ,CAAC,UAAU,CAAC;;+CACa;AAGlC;IADC,iBAAQ,CAAC,WAAW,CAAC;;gDACa;AAGnC;IADC,eAAM,EAAE;sCACI,4BAAmB;0CAAC;AAGjC;IADC,eAAM,CAAC,mBAAU,CAAC;;iDACY;AAG/B;IADC,eAAM,CAAC,oBAAW,CAAC;;kDACa;AAGjC;IADC,eAAM,EAAE;sCACS,eAAM;6CAAC;AApBd,aAAa;IADzB,gBAAO,EAAE;GACG,aAAa,CAmHzB;AAnHY,sCAAa","sourcesContent":["import {Constant, HttpServer, HttpsServer, Inject, Logger, PlatformApplication, Service} from \"@tsed/common\";\nimport type {Config} from \"apollo-server-core\";\nimport type {GraphQLSchema} from \"graphql\";\nimport type {ApolloServer, ApolloSettings} from \"../interfaces/ApolloSettings\";\n\n@Service()\nexport class ApolloService {\n @Constant(\"PLATFORM_NAME\")\n platformName: string;\n\n @Constant(\"httpPort\")\n private httpPort: string | number;\n\n @Constant(\"httpsPort\")\n private httpsPort: string | number;\n\n @Inject()\n private app: PlatformApplication;\n\n @Inject(HttpServer)\n private httpServer: HttpServer;\n\n @Inject(HttpsServer)\n private httpsServer: HttpsServer;\n\n @Inject()\n protected logger: Logger;\n\n /**\n *\n * @type {Map<any, any>}\n * @private\n */\n protected servers: Map<\n string,\n {\n instance: ApolloServer;\n schema: GraphQLSchema | undefined;\n }\n > = new Map();\n\n async createServer(id: string, settings: ApolloSettings): Promise<any> {\n if (this.has(id)) {\n return this.get(id)!;\n }\n\n try {\n const {path, installSubscriptionHandlers, serverRegistration = {}, server: customServer, ...serverSettings} = settings;\n\n this.logger.info(`Create server with Apollo for: ${id}`);\n this.logger.debug(`options: ${JSON.stringify({path})}`);\n\n const server = this.createInstance(serverSettings, customServer);\n\n if (server) {\n this.servers.set(id || \"default\", {\n instance: server,\n schema: settings.schema\n });\n\n return this.bindServer(server, settings);\n }\n } catch (err) {\n /* istanbul ignore next */\n this.logger.error(err);\n /* istanbul ignore next */\n process.exit(-1);\n }\n }\n\n /**\n * Get an instance of ApolloServer from his id\n * @returns ApolloServer\n */\n get(id: string = \"default\"): ApolloServer | undefined {\n return this.servers.get(id)?.instance;\n }\n\n /**\n * Get an instance of GraphQL schema from his id\n * @returns GraphQLSchema\n */\n getSchema(id: string = \"default\"): GraphQLSchema | undefined {\n return this.servers.get(id)?.schema;\n }\n\n /**\n *\n * @param {string} id\n * @returns {boolean}\n */\n has(id: string = \"default\"): boolean {\n return this.servers.has(id);\n }\n\n protected async bindServer(server: ApolloServer, options: ApolloSettings) {\n await server.applyMiddleware({path: options.path, ...options.serverRegistration, app: this.app.raw});\n\n if (options.installSubscriptionHandlers && (this.httpPort || this.httpsPort)) {\n this.httpPort && server.installSubscriptionHandlers(this.httpServer);\n this.httpPort && server.installSubscriptionHandlers(this.httpsServer);\n }\n\n return server;\n }\n\n protected createInstance(options: Config, server?: (config: Config) => ApolloServer): ApolloServer | undefined {\n // istanbul ignore next\n if (server) {\n return server(options);\n }\n\n // istanbul ignore next\n try {\n const Server = require(`apollo-server-${this.platformName || \"express\"}`).ApolloServer;\n\n return new Server(options);\n } catch (er) {\n this.logger.error(`Platform \"${this.platformName}\" not supported by @tsed/apollo`);\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/apollo",
3
- "version": "6.75.5",
3
+ "version": "6.75.9",
4
4
  "description": "Apollo package for Ts.ED framework",
5
5
  "main": "./lib/index.js",
6
6
  "typings": "./lib/index.d.ts",
@@ -14,8 +14,8 @@
14
14
  },
15
15
  "private": false,
16
16
  "devDependencies": {
17
- "@tsed/common": "6.75.5",
18
- "@tsed/core": "6.75.5",
17
+ "@tsed/common": "6.75.9",
18
+ "@tsed/core": "6.75.9",
19
19
  "@types/graphql": "14.5.0",
20
20
  "apollo-server-core": "^2.17.0",
21
21
  "apollo-server-testing": "2.18.2",