@tsed/apollo 7.13.6 → 7.14.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.
|
@@ -46,9 +46,14 @@ let ApolloService = class ApolloService {
|
|
|
46
46
|
return server;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
catch (
|
|
49
|
+
catch (er) {
|
|
50
50
|
/* istanbul ignore next */
|
|
51
|
-
this.logger.error(
|
|
51
|
+
this.logger.error({
|
|
52
|
+
event: "APOLLO_BOOTSTRAP_ERROR",
|
|
53
|
+
error_name: er.name,
|
|
54
|
+
message: er.message,
|
|
55
|
+
stack: er.stack
|
|
56
|
+
});
|
|
52
57
|
/* istanbul ignore next */
|
|
53
58
|
process.exit(-1);
|
|
54
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApolloService.js","sourceRoot":"","sources":["../../../src/services/ApolloService.ts"],"names":[],"mappings":";;;;AAAA,yCAAiD;AACjD,iCAAmD;AACnD,yCAAoC;AAEpC,2DAK4B;AAE5B,wDAAwB;AACxB,0DAA0B;AAK1B,IAAa,aAAa,GAA1B,MAAa,aAAa;IAExB,YAAY,CAAS;IAGX,MAAM,CAAS;IAEzB;;;;OAIG;IACO,OAAO,GAMb,IAAI,GAAG,EAAE,CAAC;IAGN,GAAG,CAA2B;IAG9B,UAAU,CAAqB;IAG/B,WAAW,CAAsB;IAEzC,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,iBAAiB,GAAG,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,EAAC,GAAG,QAAQ,CAAC;YAEjF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE,E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U,EAAE,IAAI,CAAC,UAAU;iBAC5B,CAAC;YACJ,IAAI,CAAC,WAAW;gBACd,IAAA,sDAAiC,EAAC;oBAChC,UAAU,EAAE,IAAI,CAAC,WAAW;iBAC7B,CAAC;YACJ,GAAG,CAAC,cAAc,CAAC,OAAO,IAAI,EAAE,CAAC;SAClC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC;CACF,CAAA;AArIC;IADC,IAAA,aAAQ,EAAC,eAAe,CAAC;;mDACL;AAGrB;IADC,IAAA,WAAM,GAAE;sCACS,eAAM;6CAAC;AAgBzB;IADC,IAAA,WAAM,GAAE;sCACI,4BAAmB;0CAAM;AAGtC;IADC,IAAA,WAAM,EAAC,cAAI,CAAC,MAAM,CAAC;;iDACmB;AAGvC;IADC,IAAA,WAAM,EAAC,eAAK,CAAC,MAAM,CAAC;;kDACoB;AA3B9B,aAAa;IADzB,IAAA,YAAO,GAAE;GACG,aAAa,CAuIzB;AAvIY,sCAAa","sourcesContent":["import {PlatformApplication} from \"@tsed/common\";\nimport {Constant, Inject, Service} from \"@tsed/di\";\nimport {Logger} from \"@tsed/logger\";\nimport type {Config} from \"apollo-server-core\";\nimport {\n ApolloServerBase,\n ApolloServerPluginDrainHttpServer,\n ApolloServerPluginLandingPageDisabled,\n ApolloServerPluginLandingPageGraphQLPlayground\n} from \"apollo-server-core\";\nimport type {GraphQLSchema} from \"graphql\";\nimport Http from \"http\";\nimport Https from \"https\";\nimport type {ApolloServer, ApolloSettings} from \"../interfaces/ApolloSettings\";\nimport {ApolloCustomServerCB} from \"../interfaces/ApolloSettings\";\n\n@Service()\nexport class ApolloService {\n @Constant(\"PLATFORM_NAME\")\n platformName: string;\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: ApolloServerBase;\n schema: GraphQLSchema | undefined;\n }\n > = new Map();\n\n @Inject()\n private app: PlatformApplication<any>;\n\n @Inject(Http.Server)\n private httpServer: Http.Server | null;\n\n @Inject(Https.Server)\n private httpsServer: Https.Server | null;\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, middlewareOptions = {}, server: customServer, ...config} = settings;\n\n this.logger.info(`Create server with Apollo for: ${id}`);\n this.logger.debug(`options: ${JSON.stringify({path})}`);\n\n const server = await this.createInstance(\n {\n ...config,\n plugins: this.getPlugins(settings)\n },\n customServer\n );\n\n if (server) {\n this.servers.set(id || \"default\", {\n instance: server,\n schema: settings.schema\n });\n\n await server.start();\n\n const middleware = server.getMiddleware({\n path: settings.path,\n ...middlewareOptions\n });\n\n this.app.use(middleware);\n\n return server;\n }\n } catch (er) {\n /* istanbul ignore next */\n this.logger.error({\n event: \"APOLLO_BOOTSTRAP_ERROR\",\n error_name: er.name,\n message: er.message,\n stack: er.stack\n });\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\"): ApolloServerBase | 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 createInstance(options: Config, server?: ApolloCustomServerCB): Promise<ApolloServer | undefined> {\n // istanbul ignore next\n if (server) {\n return server(options);\n }\n\n // istanbul ignore next\n try {\n const {ApolloServer: Server} = await import(`apollo-server-${this.platformName || \"express\"}`);\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 private getPlugins(serverSettings: ApolloSettings): any[] {\n const playground = serverSettings.playground || (serverSettings.playground === undefined && process.env.NODE_ENV !== \"production\");\n\n return [\n playground ? ApolloServerPluginLandingPageGraphQLPlayground() : ApolloServerPluginLandingPageDisabled(),\n this.httpServer &&\n ApolloServerPluginDrainHttpServer({\n httpServer: this.httpServer\n }),\n this.httpsServer &&\n ApolloServerPluginDrainHttpServer({\n httpServer: this.httpsServer\n }),\n ...(serverSettings.plugins || [])\n ].filter(Boolean);\n }\n}\n"]}
|
|
@@ -43,9 +43,14 @@ let ApolloService = class ApolloService {
|
|
|
43
43
|
return server;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
catch (
|
|
46
|
+
catch (er) {
|
|
47
47
|
/* istanbul ignore next */
|
|
48
|
-
this.logger.error(
|
|
48
|
+
this.logger.error({
|
|
49
|
+
event: "APOLLO_BOOTSTRAP_ERROR",
|
|
50
|
+
error_name: er.name,
|
|
51
|
+
message: er.message,
|
|
52
|
+
stack: er.stack
|
|
53
|
+
});
|
|
49
54
|
/* istanbul ignore next */
|
|
50
55
|
process.exit(-1);
|
|
51
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApolloService.js","sourceRoot":"","sources":["../../../src/services/ApolloService.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,cAAc,CAAC;AACjD,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,UAAU,CAAC;AACnD,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAEpC,OAAO,EAEL,iCAAiC,EACjC,qCAAqC,EACrC,8CAA8C,EAC/C,MAAM,oBAAoB,CAAC;AAE5B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,IAAa,aAAa,GAA1B,MAAa,aAAa;IAExB,YAAY,CAAS;IAGX,MAAM,CAAS;IAEzB;;;;OAIG;IACO,OAAO,GAMb,IAAI,GAAG,EAAE,CAAC;IAGN,GAAG,CAA2B;IAG9B,UAAU,CAAqB;IAG/B,WAAW,CAAsB;IAEzC,KAAK,C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AAM,CAAC,iBAAiB,IAAI,CAAC,YAAY,IAAI,SAAS,EAAE,CAAC,CAAC;YAE/F,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;IAEO,UAAU,CAAC,cAA8B;QAC/C,MAAM,UAAU,GAAG,cAAc,CAAC,UAAU,IAAI,CAAC,cAAc,CAAC,UAAU,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC;QAEnI,OAAO;YACL,UAAU,CAAC,CAAC,CAAC,8CAA8C,EAAE,CAAC,CAAC,CAAC,qCAAqC,EAAE;YACvG,IAAI,CAAC,UAAU;gBACb,iCAAiC,CAAC;oBAChC,UAAU,EAAE,IAAI,CAAC,UAAU;iBAC5B,CAAC;YACJ,IAAI,CAAC,WAAW;gBACd,iCAAiC,CAAC;oBAChC,UAAU,EAAE,IAAI,CAAC,WAAW;iBAC7B,CAAC;YACJ,GAAG,CAAC,cAAc,CAAC,OAAO,IAAI,EAAE,CAAC;SAClC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC;CACF,CAAA;AArIC;IADC,QAAQ,CAAC,eAAe,CAAC;;mDACL;AAGrB;IADC,MAAM,EAAE;8BACS,MAAM;6CAAC;AAgBzB;IADC,MAAM,EAAE;8BACI,mBAAmB;0CAAM;AAGtC;IADC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;;iDACmB;AAGvC;IADC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;;kDACoB;AA3B9B,aAAa;IADzB,OAAO,EAAE;GACG,aAAa,CAuIzB;SAvIY,aAAa","sourcesContent":["import {PlatformApplication} from \"@tsed/common\";\nimport {Constant, Inject, Service} from \"@tsed/di\";\nimport {Logger} from \"@tsed/logger\";\nimport type {Config} from \"apollo-server-core\";\nimport {\n ApolloServerBase,\n ApolloServerPluginDrainHttpServer,\n ApolloServerPluginLandingPageDisabled,\n ApolloServerPluginLandingPageGraphQLPlayground\n} from \"apollo-server-core\";\nimport type {GraphQLSchema} from \"graphql\";\nimport Http from \"http\";\nimport Https from \"https\";\nimport type {ApolloServer, ApolloSettings} from \"../interfaces/ApolloSettings\";\nimport {ApolloCustomServerCB} from \"../interfaces/ApolloSettings\";\n\n@Service()\nexport class ApolloService {\n @Constant(\"PLATFORM_NAME\")\n platformName: string;\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: ApolloServerBase;\n schema: GraphQLSchema | undefined;\n }\n > = new Map();\n\n @Inject()\n private app: PlatformApplication<any>;\n\n @Inject(Http.Server)\n private httpServer: Http.Server | null;\n\n @Inject(Https.Server)\n private httpsServer: Https.Server | null;\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, middlewareOptions = {}, server: customServer, ...config} = settings;\n\n this.logger.info(`Create server with Apollo for: ${id}`);\n this.logger.debug(`options: ${JSON.stringify({path})}`);\n\n const server = await this.createInstance(\n {\n ...config,\n plugins: this.getPlugins(settings)\n },\n customServer\n );\n\n if (server) {\n this.servers.set(id || \"default\", {\n instance: server,\n schema: settings.schema\n });\n\n await server.start();\n\n const middleware = server.getMiddleware({\n path: settings.path,\n ...middlewareOptions\n });\n\n this.app.use(middleware);\n\n return server;\n }\n } catch (er) {\n /* istanbul ignore next */\n this.logger.error({\n event: \"APOLLO_BOOTSTRAP_ERROR\",\n error_name: er.name,\n message: er.message,\n stack: er.stack\n });\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\"): ApolloServerBase | 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 createInstance(options: Config, server?: ApolloCustomServerCB): Promise<ApolloServer | undefined> {\n // istanbul ignore next\n if (server) {\n return server(options);\n }\n\n // istanbul ignore next\n try {\n const {ApolloServer: Server} = await import(`apollo-server-${this.platformName || \"express\"}`);\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 private getPlugins(serverSettings: ApolloSettings): any[] {\n const playground = serverSettings.playground || (serverSettings.playground === undefined && process.env.NODE_ENV !== \"production\");\n\n return [\n playground ? ApolloServerPluginLandingPageGraphQLPlayground() : ApolloServerPluginLandingPageDisabled(),\n this.httpServer &&\n ApolloServerPluginDrainHttpServer({\n httpServer: this.httpServer\n }),\n this.httpsServer &&\n ApolloServerPluginDrainHttpServer({\n httpServer: this.httpsServer\n }),\n ...(serverSettings.plugins || [])\n ].filter(Boolean);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/apollo",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.14.0",
|
|
4
4
|
"description": "Apollo package for Ts.ED framework",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
},
|
|
25
25
|
"private": false,
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@tsed/common": "7.
|
|
28
|
-
"@tsed/core": "7.
|
|
29
|
-
"@tsed/di": "7.
|
|
27
|
+
"@tsed/common": "7.14.0",
|
|
28
|
+
"@tsed/core": "7.14.0",
|
|
29
|
+
"@tsed/di": "7.14.0",
|
|
30
30
|
"@tsed/logger": ">=6.2.2",
|
|
31
31
|
"@types/graphql": "14.5.0",
|
|
32
32
|
"apollo-datasource": "^3.2.0",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"graphql": "15.7.2"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@tsed/common": "^7.
|
|
42
|
-
"@tsed/core": "^7.
|
|
43
|
-
"@tsed/di": "^7.
|
|
41
|
+
"@tsed/common": "^7.14.0",
|
|
42
|
+
"@tsed/core": "^7.14.0",
|
|
43
|
+
"@tsed/di": "^7.14.0",
|
|
44
44
|
"@tsed/logger": ">=6.2.2",
|
|
45
45
|
"apollo-datasource": ">=3.0.0",
|
|
46
46
|
"apollo-datasource-rest": ">=3.0.0",
|