@tsed/typegraphql 7.81.0-rc.1 → 7.81.1
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.
- package/.nycrc +27 -0
- package/lib/cjs/TypeGraphQLModule.js +30 -37
- package/lib/cjs/TypeGraphQLModule.js.map +1 -1
- package/lib/cjs/decorators/resolver.js +8 -1
- package/lib/cjs/decorators/resolver.js.map +1 -1
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces/interfaces.js +2 -0
- package/lib/cjs/interfaces/interfaces.js.map +1 -1
- package/lib/cjs/services/TypeGraphQLService.js +124 -0
- package/lib/cjs/services/TypeGraphQLService.js.map +1 -0
- package/lib/esm/TypeGraphQLModule.js +30 -37
- package/lib/esm/TypeGraphQLModule.js.map +1 -1
- package/lib/esm/decorators/resolver.js +6 -0
- package/lib/esm/decorators/resolver.js.map +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/interfaces.js +1 -1
- package/lib/esm/interfaces/interfaces.js.map +1 -1
- package/lib/esm/services/TypeGraphQLService.js +121 -0
- package/lib/esm/services/TypeGraphQLService.js.map +1 -0
- package/lib/types/TypeGraphQLModule.d.ts +9 -6
- package/lib/types/decorators/resolver.d.ts +12 -4
- package/lib/types/index.d.ts +1 -0
- package/lib/types/interfaces/TypeGraphQLSettings.d.ts +6 -1
- package/lib/types/interfaces/interfaces.d.ts +4 -13
- package/lib/types/services/TypeGraphQLService.d.ts +36 -0
- package/lib/types-esm/TypeGraphQLModule.d.ts +9 -6
- package/lib/types-esm/decorators/resolver.d.ts +12 -4
- package/lib/types-esm/index.d.ts +1 -0
- package/lib/types-esm/interfaces/TypeGraphQLSettings.d.ts +6 -1
- package/lib/types-esm/interfaces/interfaces.d.ts +4 -13
- package/lib/types-esm/services/TypeGraphQLService.d.ts +36 -0
- package/package.json +13 -22
- package/readme.md +6 -5
package/.nycrc
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": [
|
|
3
|
+
"src/**/*.ts"
|
|
4
|
+
],
|
|
5
|
+
"exclude": [
|
|
6
|
+
"**/*.d.ts",
|
|
7
|
+
"**/*.spec.ts",
|
|
8
|
+
"node_modules",
|
|
9
|
+
"**/interfaces/**",
|
|
10
|
+
"**/index.ts"
|
|
11
|
+
],
|
|
12
|
+
"extension": [
|
|
13
|
+
".ts"
|
|
14
|
+
],
|
|
15
|
+
"require": [],
|
|
16
|
+
"reporter": [
|
|
17
|
+
"text-summary",
|
|
18
|
+
"html",
|
|
19
|
+
"lcov",
|
|
20
|
+
"json"
|
|
21
|
+
],
|
|
22
|
+
"check-coverage": true,
|
|
23
|
+
"statements": 99.14,
|
|
24
|
+
"branches": 70.45,
|
|
25
|
+
"functions": 100,
|
|
26
|
+
"lines": 100
|
|
27
|
+
}
|
|
@@ -2,53 +2,46 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypeGraphQLModule = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const core_1 = require("@tsed/core");
|
|
6
5
|
const di_1 = require("@tsed/di");
|
|
7
|
-
const
|
|
8
|
-
const constants_js_1 = require("./constants/constants.js");
|
|
9
|
-
require("./interfaces/interfaces.js");
|
|
10
|
-
const ContextMiddleware_js_1 = require("./middlewares/ContextMiddleware.js");
|
|
6
|
+
const TypeGraphQLService_js_1 = require("./services/TypeGraphQLService.js");
|
|
11
7
|
/**
|
|
12
8
|
* @ignore
|
|
13
9
|
*/
|
|
14
10
|
let TypeGraphQLModule = class TypeGraphQLModule {
|
|
11
|
+
service;
|
|
15
12
|
injector;
|
|
16
13
|
configuration;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const resolvers = this.getResolvers(settings.id, [...initialResolvers, ...(buildSchemaOptions.resolvers || [])]);
|
|
20
|
-
serverOptions.schema = await (0, type_graphql_1.buildSchema)({
|
|
21
|
-
container: this.injector,
|
|
22
|
-
...buildSchemaOptions,
|
|
23
|
-
resolvers,
|
|
24
|
-
globalMiddlewares: [ContextMiddleware_js_1.ContextMiddleware, ...(buildSchemaOptions.globalMiddlewares || [])]
|
|
25
|
-
});
|
|
26
|
-
return serverOptions;
|
|
14
|
+
get settings() {
|
|
15
|
+
return this.configuration.get("graphql") || this.configuration.get("typegraphql");
|
|
27
16
|
}
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
17
|
+
$onRoutesInit() {
|
|
18
|
+
const { settings } = this;
|
|
19
|
+
if (settings) {
|
|
20
|
+
const promises = Object.entries(settings).map(([key, options]) => {
|
|
21
|
+
return this.service.createServer(key, options);
|
|
22
|
+
});
|
|
23
|
+
return Promise.all(promises);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
$afterListen() {
|
|
27
|
+
const host = this.configuration.getBestHost();
|
|
28
|
+
const displayLog = (key, path) => {
|
|
29
|
+
const url = typeof host.port === "number" ? `${host.protocol}://${host.address}:${host.port}` : "";
|
|
30
|
+
this.injector.logger.info(`[${key}] GraphQL server is available on ${url}/${path.replace(/^\//, "")}`);
|
|
31
|
+
};
|
|
32
|
+
const { settings } = this;
|
|
33
|
+
if (settings) {
|
|
34
|
+
Object.entries(settings).map(([key, options]) => {
|
|
35
|
+
const { path } = options;
|
|
36
|
+
displayLog(key, path);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
50
39
|
}
|
|
51
40
|
};
|
|
41
|
+
tslib_1.__decorate([
|
|
42
|
+
(0, di_1.Inject)(),
|
|
43
|
+
tslib_1.__metadata("design:type", TypeGraphQLService_js_1.TypeGraphQLService)
|
|
44
|
+
], TypeGraphQLModule.prototype, "service", void 0);
|
|
52
45
|
tslib_1.__decorate([
|
|
53
46
|
(0, di_1.Inject)(),
|
|
54
47
|
tslib_1.__metadata("design:type", di_1.InjectorService)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeGraphQLModule.js","sourceRoot":"","sources":["../../src/TypeGraphQLModule.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"TypeGraphQLModule.js","sourceRoot":"","sources":["../../src/TypeGraphQLModule.ts"],"names":[],"mappings":";;;;AAAA,iCAAwE;AAExE,4EAAoE;AAEpE;;GAEG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAElB,OAAO,CAAqB;IAG5B,QAAQ,CAAkB;IAG1B,aAAa,CAAgB;IAEvC,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACpF,CAAC;IAED,aAAa;QACX,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QACxB,IAAI,QAAQ,EAAE;YACZ,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE;gBAC/D,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,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,oCAAoC,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;QACzG,CAAC,CAAC;QAEF,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QAExB,IAAI,QAAQ,EAAE;YACZ,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE;gBAC9C,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;IAAC,IAAA,WAAM,GAAE;sCACU,0CAAkB;kDAAC;AAEtC;IAAC,IAAA,WAAM,GAAE;sCACW,oBAAe;mDAAC;AAEpC;IAAC,IAAA,kBAAa,GAAE;;wDACuB;AAR5B,iBAAiB;IAD7B,IAAA,WAAM,GAAE;GACI,iBAAiB,CA4C7B;AA5CY,8CAAiB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResolverController = void 0;
|
|
3
|
+
exports.ResolverService = exports.ResolverController = void 0;
|
|
4
4
|
const core_1 = require("@tsed/core");
|
|
5
5
|
const di_1 = require("@tsed/di");
|
|
6
6
|
const type_graphql_1 = require("type-graphql");
|
|
@@ -29,4 +29,11 @@ function ResolverController(...args) {
|
|
|
29
29
|
}));
|
|
30
30
|
}
|
|
31
31
|
exports.ResolverController = ResolverController;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use ResolverController instead
|
|
34
|
+
*/
|
|
35
|
+
function ResolverService(...args) {
|
|
36
|
+
return ResolverController(...args);
|
|
37
|
+
}
|
|
38
|
+
exports.ResolverService = ResolverService;
|
|
32
39
|
//# sourceMappingURL=resolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../src/decorators/resolver.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,iCAAoC;AACpC,+CAAiD;
|
|
1
|
+
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../src/decorators/resolver.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,iCAAoC;AACpC,+CAAiD;AAEjD,4DAA8D;AAU9D,SAAgB,kBAAkB,CAAC,GAAG,IAAW;IAC/C,IAAI,EAAE,GAAG,SAAS,CAAC;IACnB,QAAQ,IAAI,CAAC,MAAM,EAAE;QACnB,KAAK,CAAC;YACJ,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;gBAC/B,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;aACd;iBAAM;gBACL,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAChB,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aACnB;YACD,MAAM;QACR,KAAK,CAAC;YACJ,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAClB,MAAM;KACT;IACD,OAAO,IAAA,oBAAa,EACjB,uBAAgB,CAAC,GAAG,IAAI,CAAC,EAC1B,IAAA,eAAU,EAAC;QACT,IAAI,EAAE,kCAAmB;KAC1B,CAAC,EACF,IAAA,eAAQ,EAAC,SAAS,EAAE;QAClB,EAAE;KACH,CAAC,CACH,CAAC;AACJ,CAAC;AAzBD,gDAyBC;AASD;;GAEG;AACH,SAAgB,eAAe,CAAC,GAAG,IAAW;IAC5C,OAAQ,kBAA0B,CAAC,GAAG,IAAI,CAAC,CAAC;AAC9C,CAAC;AAFD,0CAEC"}
|
package/lib/cjs/index.js
CHANGED
|
@@ -10,5 +10,6 @@ tslib_1.__exportStar(require("./exports.js"), exports);
|
|
|
10
10
|
tslib_1.__exportStar(require("./interfaces/interfaces.js"), exports);
|
|
11
11
|
tslib_1.__exportStar(require("./interfaces/TypeGraphQLSettings.js"), exports);
|
|
12
12
|
tslib_1.__exportStar(require("./middlewares/ContextMiddleware.js"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./services/TypeGraphQLService.js"), exports);
|
|
13
14
|
tslib_1.__exportStar(require("./TypeGraphQLModule.js"), exports);
|
|
14
15
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,mEAAyC;AACzC,mEAAyC;AACzC,uDAA6B;AAC7B,qEAA2C;AAC3C,8EAAoD;AACpD,6EAAmD;AACnD,iEAAuC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,mEAAyC;AACzC,mEAAyC;AACzC,uDAA6B;AAC7B,qEAA2C;AAC3C,8EAAoD;AACpD,6EAAmD;AACnD,2EAAiD;AACjD,iEAAuC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":";;;AAWA,mEAAyC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypeGraphQLService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const apollo_1 = require("@tsed/apollo");
|
|
6
|
+
const core_1 = require("@tsed/core");
|
|
7
|
+
const di_1 = require("@tsed/di");
|
|
8
|
+
const logger_1 = require("@tsed/logger");
|
|
9
|
+
const type_graphql_1 = require("type-graphql");
|
|
10
|
+
const constants_js_1 = require("../constants/constants.js");
|
|
11
|
+
const ContextMiddleware_js_1 = require("../middlewares/ContextMiddleware.js");
|
|
12
|
+
const getKey = (id) => `typegraphql-${id}`;
|
|
13
|
+
let TypeGraphQLService = class TypeGraphQLService {
|
|
14
|
+
injector;
|
|
15
|
+
apolloService;
|
|
16
|
+
logger;
|
|
17
|
+
/**
|
|
18
|
+
* Get an instance of ApolloServer from his id
|
|
19
|
+
* @returns ApolloServer
|
|
20
|
+
*/
|
|
21
|
+
get(id = "default") {
|
|
22
|
+
return this.apolloService.get(getKey(id));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param {string} id
|
|
27
|
+
* @returns {boolean}
|
|
28
|
+
*/
|
|
29
|
+
has(id = "default") {
|
|
30
|
+
return this.apolloService.has(getKey(id));
|
|
31
|
+
}
|
|
32
|
+
async createServer(id, settings) {
|
|
33
|
+
if (!this.has(id)) {
|
|
34
|
+
try {
|
|
35
|
+
const { dataSources, resolvers: initialResolvers = [], buildSchemaOptions = {}, serverConfig = {}, ...serverOptions } = settings;
|
|
36
|
+
const resolvers = this.getResolvers(id, [...initialResolvers, ...(buildSchemaOptions.resolvers || [])]);
|
|
37
|
+
const schema = await this.createSchema({
|
|
38
|
+
container: this.injector,
|
|
39
|
+
...buildSchemaOptions,
|
|
40
|
+
resolvers,
|
|
41
|
+
globalMiddlewares: [ContextMiddleware_js_1.ContextMiddleware, ...(buildSchemaOptions.globalMiddlewares || [])]
|
|
42
|
+
});
|
|
43
|
+
return await this.apolloService.createServer(getKey(id), {
|
|
44
|
+
...serverOptions,
|
|
45
|
+
...serverConfig,
|
|
46
|
+
resolvers,
|
|
47
|
+
dataSources: () => {
|
|
48
|
+
return {
|
|
49
|
+
...(dataSources ? dataSources() : {}),
|
|
50
|
+
...(serverConfig.dataSources ? serverConfig.dataSources() : {})
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
schema
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (er) {
|
|
57
|
+
/* istanbul ignore next */
|
|
58
|
+
this.logger.error({
|
|
59
|
+
event: "TYPEGRAPHQL_BOOTSTRAP_ERROR",
|
|
60
|
+
error_name: er.name,
|
|
61
|
+
message: er.message,
|
|
62
|
+
stack: er.stack
|
|
63
|
+
});
|
|
64
|
+
/* istanbul ignore next */
|
|
65
|
+
process.exit(-1);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return this.get(id);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create a new type-graphql Schema and bind it with Ts.ED injector.
|
|
72
|
+
* @param buildSchemaOptions
|
|
73
|
+
*/
|
|
74
|
+
createSchema(buildSchemaOptions) {
|
|
75
|
+
return (0, type_graphql_1.buildSchema)(buildSchemaOptions);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get an instance of GraphQL schema from his id
|
|
79
|
+
* @returns GraphQLSchema
|
|
80
|
+
*/
|
|
81
|
+
getSchema(id = "default") {
|
|
82
|
+
return this.apolloService.getSchema(getKey(id));
|
|
83
|
+
}
|
|
84
|
+
getResolvers(id, resolvers) {
|
|
85
|
+
const globalResolvers = this.injector
|
|
86
|
+
.getProviders(constants_js_1.RESOLVERS_PROVIDERS)
|
|
87
|
+
.filter((provider) => {
|
|
88
|
+
const opts = provider.store.get("graphql");
|
|
89
|
+
return !opts?.id || opts?.id === id;
|
|
90
|
+
})
|
|
91
|
+
.map((provider) => {
|
|
92
|
+
return provider.useClass;
|
|
93
|
+
});
|
|
94
|
+
return resolvers
|
|
95
|
+
.map((resolver) => {
|
|
96
|
+
if (!(this.injector.has(resolver) || !(0, core_1.isClass)(resolver))) {
|
|
97
|
+
this.injector
|
|
98
|
+
.addProvider(resolver, {
|
|
99
|
+
useClass: resolver
|
|
100
|
+
})
|
|
101
|
+
.invoke(resolver);
|
|
102
|
+
}
|
|
103
|
+
return resolver;
|
|
104
|
+
})
|
|
105
|
+
.concat(globalResolvers);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
tslib_1.__decorate([
|
|
109
|
+
(0, di_1.Inject)(),
|
|
110
|
+
tslib_1.__metadata("design:type", di_1.InjectorService)
|
|
111
|
+
], TypeGraphQLService.prototype, "injector", void 0);
|
|
112
|
+
tslib_1.__decorate([
|
|
113
|
+
(0, di_1.Inject)(),
|
|
114
|
+
tslib_1.__metadata("design:type", apollo_1.ApolloService)
|
|
115
|
+
], TypeGraphQLService.prototype, "apolloService", void 0);
|
|
116
|
+
tslib_1.__decorate([
|
|
117
|
+
(0, di_1.Inject)(),
|
|
118
|
+
tslib_1.__metadata("design:type", logger_1.Logger)
|
|
119
|
+
], TypeGraphQLService.prototype, "logger", void 0);
|
|
120
|
+
TypeGraphQLService = tslib_1.__decorate([
|
|
121
|
+
(0, di_1.Injectable)()
|
|
122
|
+
], TypeGraphQLService);
|
|
123
|
+
exports.TypeGraphQLService = TypeGraphQLService;
|
|
124
|
+
//# sourceMappingURL=TypeGraphQLService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeGraphQLService.js","sourceRoot":"","sources":["../../../src/services/TypeGraphQLService.ts"],"names":[],"mappings":";;;;AAAA,yCAA2C;AAC3C,qCAAyC;AACzC,iCAA6D;AAC7D,yCAAoC;AAGpC,+CAA6D;AAC7D,4DAA8D;AAE9D,8EAAsE;AAEtE,MAAM,MAAM,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,eAAe,EAAE,EA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tC,CAAC,CAAC;aACD,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YAChB,OAAO,QAAQ,CAAC,QAAQ,CAAC;QAC3B,CAAC,CAAC,CAAC;QAEL,OAAO,SAAS;aACb,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YAChB,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAA,cAAO,EAAC,QAAQ,CAAC,CAAC,EAAE;gBACxD,IAAI,CAAC,QAAQ;qBACV,WAAW,CAAC,QAAQ,EAAE;oBACrB,QAAQ,EAAE,QAAQ;iBACnB,CAAC;qBACD,MAAM,CAAC,QAAQ,CAAC,CAAC;aACrB;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC,CAAC;aACD,MAAM,CAAC,eAAe,CAAC,CAAC;IAC7B,CAAC;CACF,CAAA;AA9GC;IAAC,IAAA,WAAM,GAAE;sCACW,oBAAe;oDAAC;AAEpC;IAAC,IAAA,WAAM,GAAE;sCACgB,sBAAa;yDAAC;AAEvC;IAAC,IAAA,WAAM,GAAE;sCACS,eAAM;kDAAC;AARd,kBAAkB;IAD9B,IAAA,eAAU,GAAE;GACA,kBAAkB,CA+G9B;AA/GY,gDAAkB"}
|
|
@@ -1,51 +1,44 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { isClass } from "@tsed/core";
|
|
3
2
|
import { Configuration, Inject, InjectorService, Module } from "@tsed/di";
|
|
4
|
-
import {
|
|
5
|
-
import { RESOLVERS_PROVIDERS } from "./constants/constants.js";
|
|
6
|
-
import "./interfaces/interfaces.js";
|
|
7
|
-
import { ContextMiddleware } from "./middlewares/ContextMiddleware.js";
|
|
3
|
+
import { TypeGraphQLService } from "./services/TypeGraphQLService.js";
|
|
8
4
|
/**
|
|
9
5
|
* @ignore
|
|
10
6
|
*/
|
|
11
7
|
let TypeGraphQLModule = class TypeGraphQLModule {
|
|
8
|
+
service;
|
|
12
9
|
injector;
|
|
13
10
|
configuration;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const resolvers = this.getResolvers(settings.id, [...initialResolvers, ...(buildSchemaOptions.resolvers || [])]);
|
|
17
|
-
serverOptions.schema = await buildSchema({
|
|
18
|
-
container: this.injector,
|
|
19
|
-
...buildSchemaOptions,
|
|
20
|
-
resolvers,
|
|
21
|
-
globalMiddlewares: [ContextMiddleware, ...(buildSchemaOptions.globalMiddlewares || [])]
|
|
22
|
-
});
|
|
23
|
-
return serverOptions;
|
|
11
|
+
get settings() {
|
|
12
|
+
return this.configuration.get("graphql") || this.configuration.get("typegraphql");
|
|
24
13
|
}
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
14
|
+
$onRoutesInit() {
|
|
15
|
+
const { settings } = this;
|
|
16
|
+
if (settings) {
|
|
17
|
+
const promises = Object.entries(settings).map(([key, options]) => {
|
|
18
|
+
return this.service.createServer(key, options);
|
|
19
|
+
});
|
|
20
|
+
return Promise.all(promises);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
$afterListen() {
|
|
24
|
+
const host = this.configuration.getBestHost();
|
|
25
|
+
const displayLog = (key, path) => {
|
|
26
|
+
const url = typeof host.port === "number" ? `${host.protocol}://${host.address}:${host.port}` : "";
|
|
27
|
+
this.injector.logger.info(`[${key}] GraphQL server is available on ${url}/${path.replace(/^\//, "")}`);
|
|
28
|
+
};
|
|
29
|
+
const { settings } = this;
|
|
30
|
+
if (settings) {
|
|
31
|
+
Object.entries(settings).map(([key, options]) => {
|
|
32
|
+
const { path } = options;
|
|
33
|
+
displayLog(key, path);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
47
36
|
}
|
|
48
37
|
};
|
|
38
|
+
__decorate([
|
|
39
|
+
Inject(),
|
|
40
|
+
__metadata("design:type", TypeGraphQLService)
|
|
41
|
+
], TypeGraphQLModule.prototype, "service", void 0);
|
|
49
42
|
__decorate([
|
|
50
43
|
Inject(),
|
|
51
44
|
__metadata("design:type", InjectorService)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeGraphQLModule.js","sourceRoot":"","sources":["../../src/TypeGraphQLModule.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"TypeGraphQLModule.js","sourceRoot":"","sources":["../../src/TypeGraphQLModule.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,aAAa,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AAExE,OAAO,EAAC,kBAAkB,EAAC,MAAM,kCAAkC,CAAC;AAEpE;;GAEG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAElB,OAAO,CAAqB;IAG5B,QAAQ,CAAkB;IAG1B,aAAa,CAAgB;IAEvC,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACpF,CAAC;IAED,aAAa;QACX,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QACxB,IAAI,QAAQ,EAAE;YACZ,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE;gBAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACjD,CAAC,CAAC,CAAC;YAEH,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CA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}
|
package/lib/esm/index.js
CHANGED
|
@@ -7,5 +7,6 @@ export * from "./exports.js";
|
|
|
7
7
|
export * from "./interfaces/interfaces.js";
|
|
8
8
|
export * from "./interfaces/TypeGraphQLSettings.js";
|
|
9
9
|
export * from "./middlewares/ContextMiddleware.js";
|
|
10
|
+
export * from "./services/TypeGraphQLService.js";
|
|
10
11
|
export * from "./TypeGraphQLModule.js";
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qCAAqC,CAAC;AACpD,cAAc,oCAAoC,CAAC;AACnD,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qCAAqC,CAAC;AACpD,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./TypeGraphQLSettings.js";
|
|
2
2
|
//# sourceMappingURL=interfaces.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":"AAWA,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { ApolloService } from "@tsed/apollo";
|
|
3
|
+
import { isClass } from "@tsed/core";
|
|
4
|
+
import { Inject, Injectable, InjectorService } from "@tsed/di";
|
|
5
|
+
import { Logger } from "@tsed/logger";
|
|
6
|
+
import { buildSchema } from "type-graphql";
|
|
7
|
+
import { RESOLVERS_PROVIDERS } from "../constants/constants.js";
|
|
8
|
+
import { ContextMiddleware } from "../middlewares/ContextMiddleware.js";
|
|
9
|
+
const getKey = (id) => `typegraphql-${id}`;
|
|
10
|
+
let TypeGraphQLService = class TypeGraphQLService {
|
|
11
|
+
injector;
|
|
12
|
+
apolloService;
|
|
13
|
+
logger;
|
|
14
|
+
/**
|
|
15
|
+
* Get an instance of ApolloServer from his id
|
|
16
|
+
* @returns ApolloServer
|
|
17
|
+
*/
|
|
18
|
+
get(id = "default") {
|
|
19
|
+
return this.apolloService.get(getKey(id));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param {string} id
|
|
24
|
+
* @returns {boolean}
|
|
25
|
+
*/
|
|
26
|
+
has(id = "default") {
|
|
27
|
+
return this.apolloService.has(getKey(id));
|
|
28
|
+
}
|
|
29
|
+
async createServer(id, settings) {
|
|
30
|
+
if (!this.has(id)) {
|
|
31
|
+
try {
|
|
32
|
+
const { dataSources, resolvers: initialResolvers = [], buildSchemaOptions = {}, serverConfig = {}, ...serverOptions } = settings;
|
|
33
|
+
const resolvers = this.getResolvers(id, [...initialResolvers, ...(buildSchemaOptions.resolvers || [])]);
|
|
34
|
+
const schema = await this.createSchema({
|
|
35
|
+
container: this.injector,
|
|
36
|
+
...buildSchemaOptions,
|
|
37
|
+
resolvers,
|
|
38
|
+
globalMiddlewares: [ContextMiddleware, ...(buildSchemaOptions.globalMiddlewares || [])]
|
|
39
|
+
});
|
|
40
|
+
return await this.apolloService.createServer(getKey(id), {
|
|
41
|
+
...serverOptions,
|
|
42
|
+
...serverConfig,
|
|
43
|
+
resolvers,
|
|
44
|
+
dataSources: () => {
|
|
45
|
+
return {
|
|
46
|
+
...(dataSources ? dataSources() : {}),
|
|
47
|
+
...(serverConfig.dataSources ? serverConfig.dataSources() : {})
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
schema
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (er) {
|
|
54
|
+
/* istanbul ignore next */
|
|
55
|
+
this.logger.error({
|
|
56
|
+
event: "TYPEGRAPHQL_BOOTSTRAP_ERROR",
|
|
57
|
+
error_name: er.name,
|
|
58
|
+
message: er.message,
|
|
59
|
+
stack: er.stack
|
|
60
|
+
});
|
|
61
|
+
/* istanbul ignore next */
|
|
62
|
+
process.exit(-1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return this.get(id);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Create a new type-graphql Schema and bind it with Ts.ED injector.
|
|
69
|
+
* @param buildSchemaOptions
|
|
70
|
+
*/
|
|
71
|
+
createSchema(buildSchemaOptions) {
|
|
72
|
+
return buildSchema(buildSchemaOptions);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get an instance of GraphQL schema from his id
|
|
76
|
+
* @returns GraphQLSchema
|
|
77
|
+
*/
|
|
78
|
+
getSchema(id = "default") {
|
|
79
|
+
return this.apolloService.getSchema(getKey(id));
|
|
80
|
+
}
|
|
81
|
+
getResolvers(id, resolvers) {
|
|
82
|
+
const globalResolvers = this.injector
|
|
83
|
+
.getProviders(RESOLVERS_PROVIDERS)
|
|
84
|
+
.filter((provider) => {
|
|
85
|
+
const opts = provider.store.get("graphql");
|
|
86
|
+
return !opts?.id || opts?.id === id;
|
|
87
|
+
})
|
|
88
|
+
.map((provider) => {
|
|
89
|
+
return provider.useClass;
|
|
90
|
+
});
|
|
91
|
+
return resolvers
|
|
92
|
+
.map((resolver) => {
|
|
93
|
+
if (!(this.injector.has(resolver) || !isClass(resolver))) {
|
|
94
|
+
this.injector
|
|
95
|
+
.addProvider(resolver, {
|
|
96
|
+
useClass: resolver
|
|
97
|
+
})
|
|
98
|
+
.invoke(resolver);
|
|
99
|
+
}
|
|
100
|
+
return resolver;
|
|
101
|
+
})
|
|
102
|
+
.concat(globalResolvers);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
__decorate([
|
|
106
|
+
Inject(),
|
|
107
|
+
__metadata("design:type", InjectorService)
|
|
108
|
+
], TypeGraphQLService.prototype, "injector", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
Inject(),
|
|
111
|
+
__metadata("design:type", ApolloService)
|
|
112
|
+
], TypeGraphQLService.prototype, "apolloService", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
Inject(),
|
|
115
|
+
__metadata("design:type", Logger)
|
|
116
|
+
], TypeGraphQLService.prototype, "logger", void 0);
|
|
117
|
+
TypeGraphQLService = __decorate([
|
|
118
|
+
Injectable()
|
|
119
|
+
], TypeGraphQLService);
|
|
120
|
+
export { TypeGraphQLService };
|
|
121
|
+
//# sourceMappingURL=TypeGraphQLService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeGraphQLService.js","sourceRoot":"","sources":["../../../src/services/TypeGraphQLService.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAC,OAAO,EAAO,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAGpC,OAAO,EAAC,WAAW,EAAqB,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAC,mBAAmB,EAAC,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAC,iBAAiB,EAAC,MAAM,qCAAqC,CAAC;AAEtE,MAAM,MAAM,GAAG,CAAC,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AAE,EAAE,KAAK,EAAE,CAAC;QACtC,CAAC,CAAC;aACD,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YAChB,OAAO,QAAQ,CAAC,QAAQ,CAAC;QAC3B,CAAC,CAAC,CAAC;QAEL,OAAO,SAAS;aACb,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YAChB,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE;gBACxD,IAAI,CAAC,QAAQ;qBACV,WAAW,CAAC,QAAQ,EAAE;oBACrB,QAAQ,EAAE,QAAQ;iBACnB,CAAC;qBACD,MAAM,CAAC,QAAQ,CAAC,CAAC;aACrB;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC,CAAC;aACD,MAAM,CAAC,eAAe,CAAC,CAAC;IAC7B,CAAC;CACF,CAAA;AA9GC;IAAC,MAAM,EAAE;8BACW,eAAe;oDAAC;AAEpC;IAAC,MAAM,EAAE;8BACgB,aAAa;yDAAC;AAEvC;IAAC,MAAM,EAAE;8BACS,MAAM;kDAAC;AARd,kBAAkB;IAD9B,UAAU,EAAE;GACA,kBAAkB,CA+G9B;SA/GY,kBAAkB"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { AlterApolloSettings, ApolloSettingsWithID } from "@tsed/apollo";
|
|
2
|
-
import { Type } from "@tsed/core";
|
|
3
1
|
import { Configuration, InjectorService } from "@tsed/di";
|
|
4
|
-
import "./interfaces/interfaces.js";
|
|
2
|
+
import { TypeGraphQLSettings } from "./interfaces/interfaces.js";
|
|
3
|
+
import { TypeGraphQLService } from "./services/TypeGraphQLService.js";
|
|
5
4
|
/**
|
|
6
5
|
* @ignore
|
|
7
6
|
*/
|
|
8
|
-
export declare class TypeGraphQLModule
|
|
7
|
+
export declare class TypeGraphQLModule {
|
|
8
|
+
protected service: TypeGraphQLService;
|
|
9
9
|
protected injector: InjectorService;
|
|
10
10
|
protected configuration: Configuration;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
get settings(): {
|
|
12
|
+
[key: string]: TypeGraphQLSettings;
|
|
13
|
+
} | undefined;
|
|
14
|
+
$onRoutesInit(): Promise<any> | void;
|
|
15
|
+
$afterListen(): Promise<any> | void;
|
|
13
16
|
}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { ClassType } from "type-graphql";
|
|
2
|
-
|
|
2
|
+
import { AbstractClassOptions, ClassTypeResolver } from "type-graphql/dist/decorators/types";
|
|
3
|
+
export interface ResolverControllerOptions extends AbstractClassOptions {
|
|
3
4
|
id?: string;
|
|
4
5
|
}
|
|
5
|
-
export declare function ResolverController(): ClassDecorator;
|
|
6
|
-
export declare function ResolverController(
|
|
7
|
-
export declare function ResolverController(typeFunc:
|
|
6
|
+
export declare function ResolverController(path?: string): ClassDecorator;
|
|
7
|
+
export declare function ResolverController(options: ResolverControllerOptions): ClassDecorator;
|
|
8
|
+
export declare function ResolverController(typeFunc: ClassTypeResolver, options?: ResolverControllerOptions): ClassDecorator;
|
|
8
9
|
export declare function ResolverController(objectType: ClassType, options?: ResolverControllerOptions): ClassDecorator;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use ResolverController instead
|
|
12
|
+
*/
|
|
13
|
+
export declare function ResolverService(): ClassDecorator;
|
|
14
|
+
export declare function ResolverService(options: AbstractClassOptions): ClassDecorator;
|
|
15
|
+
export declare function ResolverService(typeFunc: ClassTypeResolver, options?: AbstractClassOptions): ClassDecorator;
|
|
16
|
+
export declare function ResolverService(objectType: ClassType, options?: AbstractClassOptions): ClassDecorator;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -7,4 +7,5 @@ export * from "./exports.js";
|
|
|
7
7
|
export * from "./interfaces/interfaces.js";
|
|
8
8
|
export * from "./interfaces/TypeGraphQLSettings.js";
|
|
9
9
|
export * from "./middlewares/ContextMiddleware.js";
|
|
10
|
+
export * from "./services/TypeGraphQLService.js";
|
|
10
11
|
export * from "./TypeGraphQLModule.js";
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { ApolloConfig, ApolloSettings } from "@tsed/apollo";
|
|
2
|
+
import { BuildSchemaOptions } from "type-graphql";
|
|
3
|
+
export interface TypeGraphQLSettings extends ApolloSettings {
|
|
4
|
+
buildSchemaOptions?: Partial<BuildSchemaOptions>;
|
|
5
|
+
serverConfig?: ApolloConfig;
|
|
6
|
+
}
|
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { ApolloSettings as AS } from "@tsed/apollo";
|
|
1
|
+
import { TypeGraphQLSettings } from "./TypeGraphQLSettings.js";
|
|
3
2
|
declare global {
|
|
4
3
|
namespace TsED {
|
|
5
|
-
interface ApolloSettings {
|
|
6
|
-
buildSchemaOptions?: Partial<BuildSchemaOptions>;
|
|
7
|
-
}
|
|
8
4
|
interface Configuration {
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated Use apollo instead
|
|
11
|
-
*/
|
|
12
5
|
graphql: {
|
|
13
|
-
[key: string]:
|
|
6
|
+
[key: string]: TypeGraphQLSettings;
|
|
14
7
|
};
|
|
15
|
-
/**
|
|
16
|
-
* @deprecated Use apollo instead
|
|
17
|
-
*/
|
|
18
8
|
typegraphql: {
|
|
19
|
-
[key: string]:
|
|
9
|
+
[key: string]: TypeGraphQLSettings;
|
|
20
10
|
};
|
|
21
11
|
}
|
|
22
12
|
}
|
|
23
13
|
}
|
|
14
|
+
export * from "./TypeGraphQLSettings.js";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ApolloService } from "@tsed/apollo";
|
|
2
|
+
import { Type } from "@tsed/core";
|
|
3
|
+
import { InjectorService } from "@tsed/di";
|
|
4
|
+
import { Logger } from "@tsed/logger";
|
|
5
|
+
import { ApolloServerBase } from "apollo-server-core";
|
|
6
|
+
import { GraphQLSchema } from "graphql";
|
|
7
|
+
import { BuildSchemaOptions } from "type-graphql";
|
|
8
|
+
import { TypeGraphQLSettings } from "../interfaces/interfaces.js";
|
|
9
|
+
export declare class TypeGraphQLService {
|
|
10
|
+
protected injector: InjectorService;
|
|
11
|
+
protected apolloService: ApolloService;
|
|
12
|
+
protected logger: Logger;
|
|
13
|
+
/**
|
|
14
|
+
* Get an instance of ApolloServer from his id
|
|
15
|
+
* @returns ApolloServer
|
|
16
|
+
*/
|
|
17
|
+
get(id?: string): ApolloServerBase | undefined;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param {string} id
|
|
21
|
+
* @returns {boolean}
|
|
22
|
+
*/
|
|
23
|
+
has(id?: string): boolean;
|
|
24
|
+
createServer(id: string, settings: TypeGraphQLSettings): Promise<ApolloServerBase<any>>;
|
|
25
|
+
/**
|
|
26
|
+
* Create a new type-graphql Schema and bind it with Ts.ED injector.
|
|
27
|
+
* @param buildSchemaOptions
|
|
28
|
+
*/
|
|
29
|
+
createSchema(buildSchemaOptions: BuildSchemaOptions): Promise<GraphQLSchema>;
|
|
30
|
+
/**
|
|
31
|
+
* Get an instance of GraphQL schema from his id
|
|
32
|
+
* @returns GraphQLSchema
|
|
33
|
+
*/
|
|
34
|
+
getSchema(id?: string): GraphQLSchema | undefined;
|
|
35
|
+
protected getResolvers(id: string, resolvers: Type<any>[]): Type<any>[];
|
|
36
|
+
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { AlterApolloSettings, ApolloSettingsWithID } from "@tsed/apollo";
|
|
2
|
-
import { Type } from "@tsed/core";
|
|
3
1
|
import { Configuration, InjectorService } from "@tsed/di";
|
|
4
|
-
import "./interfaces/interfaces.js";
|
|
2
|
+
import { TypeGraphQLSettings } from "./interfaces/interfaces.js";
|
|
3
|
+
import { TypeGraphQLService } from "./services/TypeGraphQLService.js";
|
|
5
4
|
/**
|
|
6
5
|
* @ignore
|
|
7
6
|
*/
|
|
8
|
-
export declare class TypeGraphQLModule
|
|
7
|
+
export declare class TypeGraphQLModule {
|
|
8
|
+
protected service: TypeGraphQLService;
|
|
9
9
|
protected injector: InjectorService;
|
|
10
10
|
protected configuration: Configuration;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
get settings(): {
|
|
12
|
+
[key: string]: TypeGraphQLSettings;
|
|
13
|
+
} | undefined;
|
|
14
|
+
$onRoutesInit(): Promise<any> | void;
|
|
15
|
+
$afterListen(): Promise<any> | void;
|
|
13
16
|
}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { ClassType } from "type-graphql";
|
|
2
|
-
|
|
2
|
+
import { AbstractClassOptions, ClassTypeResolver } from "type-graphql/dist/decorators/types";
|
|
3
|
+
export interface ResolverControllerOptions extends AbstractClassOptions {
|
|
3
4
|
id?: string;
|
|
4
5
|
}
|
|
5
|
-
export declare function ResolverController(): ClassDecorator;
|
|
6
|
-
export declare function ResolverController(
|
|
7
|
-
export declare function ResolverController(typeFunc:
|
|
6
|
+
export declare function ResolverController(path?: string): ClassDecorator;
|
|
7
|
+
export declare function ResolverController(options: ResolverControllerOptions): ClassDecorator;
|
|
8
|
+
export declare function ResolverController(typeFunc: ClassTypeResolver, options?: ResolverControllerOptions): ClassDecorator;
|
|
8
9
|
export declare function ResolverController(objectType: ClassType, options?: ResolverControllerOptions): ClassDecorator;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use ResolverController instead
|
|
12
|
+
*/
|
|
13
|
+
export declare function ResolverService(): ClassDecorator;
|
|
14
|
+
export declare function ResolverService(options: AbstractClassOptions): ClassDecorator;
|
|
15
|
+
export declare function ResolverService(typeFunc: ClassTypeResolver, options?: AbstractClassOptions): ClassDecorator;
|
|
16
|
+
export declare function ResolverService(objectType: ClassType, options?: AbstractClassOptions): ClassDecorator;
|
package/lib/types-esm/index.d.ts
CHANGED
|
@@ -7,4 +7,5 @@ export * from "./exports.js";
|
|
|
7
7
|
export * from "./interfaces/interfaces.js";
|
|
8
8
|
export * from "./interfaces/TypeGraphQLSettings.js";
|
|
9
9
|
export * from "./middlewares/ContextMiddleware.js";
|
|
10
|
+
export * from "./services/TypeGraphQLService.js";
|
|
10
11
|
export * from "./TypeGraphQLModule.js";
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { ApolloConfig, ApolloSettings } from "@tsed/apollo";
|
|
2
|
+
import { BuildSchemaOptions } from "type-graphql";
|
|
3
|
+
export interface TypeGraphQLSettings extends ApolloSettings {
|
|
4
|
+
buildSchemaOptions?: Partial<BuildSchemaOptions>;
|
|
5
|
+
serverConfig?: ApolloConfig;
|
|
6
|
+
}
|
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { ApolloSettings as AS } from "@tsed/apollo";
|
|
1
|
+
import { TypeGraphQLSettings } from "./TypeGraphQLSettings.js";
|
|
3
2
|
declare global {
|
|
4
3
|
namespace TsED {
|
|
5
|
-
interface ApolloSettings {
|
|
6
|
-
buildSchemaOptions?: Partial<BuildSchemaOptions>;
|
|
7
|
-
}
|
|
8
4
|
interface Configuration {
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated Use apollo instead
|
|
11
|
-
*/
|
|
12
5
|
graphql: {
|
|
13
|
-
[key: string]:
|
|
6
|
+
[key: string]: TypeGraphQLSettings;
|
|
14
7
|
};
|
|
15
|
-
/**
|
|
16
|
-
* @deprecated Use apollo instead
|
|
17
|
-
*/
|
|
18
8
|
typegraphql: {
|
|
19
|
-
[key: string]:
|
|
9
|
+
[key: string]: TypeGraphQLSettings;
|
|
20
10
|
};
|
|
21
11
|
}
|
|
22
12
|
}
|
|
23
13
|
}
|
|
14
|
+
export * from "./TypeGraphQLSettings.js";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ApolloService } from "@tsed/apollo";
|
|
2
|
+
import { Type } from "@tsed/core";
|
|
3
|
+
import { InjectorService } from "@tsed/di";
|
|
4
|
+
import { Logger } from "@tsed/logger";
|
|
5
|
+
import { ApolloServerBase } from "apollo-server-core";
|
|
6
|
+
import { GraphQLSchema } from "graphql";
|
|
7
|
+
import { BuildSchemaOptions } from "type-graphql";
|
|
8
|
+
import { TypeGraphQLSettings } from "../interfaces/interfaces.js";
|
|
9
|
+
export declare class TypeGraphQLService {
|
|
10
|
+
protected injector: InjectorService;
|
|
11
|
+
protected apolloService: ApolloService;
|
|
12
|
+
protected logger: Logger;
|
|
13
|
+
/**
|
|
14
|
+
* Get an instance of ApolloServer from his id
|
|
15
|
+
* @returns ApolloServer
|
|
16
|
+
*/
|
|
17
|
+
get(id?: string): ApolloServerBase | undefined;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param {string} id
|
|
21
|
+
* @returns {boolean}
|
|
22
|
+
*/
|
|
23
|
+
has(id?: string): boolean;
|
|
24
|
+
createServer(id: string, settings: TypeGraphQLSettings): Promise<ApolloServerBase<any>>;
|
|
25
|
+
/**
|
|
26
|
+
* Create a new type-graphql Schema and bind it with Ts.ED injector.
|
|
27
|
+
* @param buildSchemaOptions
|
|
28
|
+
*/
|
|
29
|
+
createSchema(buildSchemaOptions: BuildSchemaOptions): Promise<GraphQLSchema>;
|
|
30
|
+
/**
|
|
31
|
+
* Get an instance of GraphQL schema from his id
|
|
32
|
+
* @returns GraphQLSchema
|
|
33
|
+
*/
|
|
34
|
+
getSchema(id?: string): GraphQLSchema | undefined;
|
|
35
|
+
protected getResolvers(id: string, resolvers: Type<any>[]): Type<any>[];
|
|
36
|
+
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tsed/typegraphql",
|
|
3
3
|
"description": "TypeGraphQL package for Ts.ED framework, based on Apollo-server-core and Type-graphql",
|
|
4
4
|
"type": "commonjs",
|
|
5
|
-
"version": "7.81.
|
|
5
|
+
"version": "7.81.1",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/cjs/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
@@ -25,35 +25,29 @@
|
|
|
25
25
|
"test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@tsed/apollo": "7.81.
|
|
28
|
+
"@tsed/apollo": "7.81.1",
|
|
29
29
|
"tslib": "2.6.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@
|
|
33
|
-
"@tsed/
|
|
34
|
-
"@tsed/
|
|
35
|
-
"@tsed/
|
|
36
|
-
"@tsed/platform-express": "7.81.0-rc.1",
|
|
37
|
-
"@tsed/typescript": "7.81.0-rc.1",
|
|
32
|
+
"@tsed/barrels": "7.81.1",
|
|
33
|
+
"@tsed/common": "7.81.1",
|
|
34
|
+
"@tsed/core": "7.81.1",
|
|
35
|
+
"@tsed/typescript": "7.81.1",
|
|
38
36
|
"@types/graphql": "^14.5.0",
|
|
39
37
|
"class-validator": "~0.14.1",
|
|
40
38
|
"cross-env": "^7.0.3",
|
|
41
39
|
"eslint": "^8.57.0",
|
|
42
|
-
"graphql": "
|
|
43
|
-
"graphql
|
|
44
|
-
"graphql-scalars": "1.23.0",
|
|
45
|
-
"jest": "^29.7.0",
|
|
46
|
-
"ts-node": "10.9.2",
|
|
47
|
-
"type-graphql": ">=2.0.0-rc.2",
|
|
40
|
+
"graphql-passport": "0.6.8",
|
|
41
|
+
"type-graphql": "^1.1.1",
|
|
48
42
|
"typescript": "4.9.5",
|
|
49
43
|
"vitest": "2.0.4"
|
|
50
44
|
},
|
|
51
45
|
"peerDependencies": {
|
|
52
|
-
"
|
|
46
|
+
"apollo-datasource": ">=3.0.0",
|
|
47
|
+
"apollo-datasource-rest": ">=3.0.0",
|
|
53
48
|
"class-validator": ">=0.13.1",
|
|
54
|
-
"graphql": ">=
|
|
55
|
-
"graphql
|
|
56
|
-
"type-graphql": ">=2.0.0-rc.2"
|
|
49
|
+
"graphql": ">=15.0.0",
|
|
50
|
+
"type-graphql": ">=1.0.0"
|
|
57
51
|
},
|
|
58
52
|
"repository": "https://github.com/tsedio/tsed",
|
|
59
53
|
"bugs": {
|
|
@@ -61,8 +55,5 @@
|
|
|
61
55
|
},
|
|
62
56
|
"homepage": "https://github.com/tsedio/tsed/tree/production/packages/graphql/typegraphql",
|
|
63
57
|
"author": "Romain Lenzotti",
|
|
64
|
-
"license": "MIT"
|
|
65
|
-
"publishConfig": {
|
|
66
|
-
"tag": "rc"
|
|
67
|
-
}
|
|
58
|
+
"license": "MIT"
|
|
68
59
|
}
|
package/readme.md
CHANGED
|
@@ -33,7 +33,7 @@ GraphQL is a query language for APIs and a runtime for fulfilling those queries
|
|
|
33
33
|
## Feature
|
|
34
34
|
|
|
35
35
|
Currently, `@tsed/typegraphql` allows you to configure a graphql server in your project.
|
|
36
|
-
This package use [
|
|
36
|
+
This package use [`apollo-server-express`](https://www.apollographql.com/docs/apollo-server/api/apollo-server.html) to create GraphQL server and [`type-graphql`](https://19majkel94.github.io/type-graphql/)
|
|
37
37
|
for the decorators.
|
|
38
38
|
|
|
39
39
|
## Installation
|
|
@@ -41,8 +41,9 @@ for the decorators.
|
|
|
41
41
|
To begin, install the TypeGraphQL module for TS.ED:
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
|
-
npm install --save @tsed/typegraphql type-graphql graphql@15
|
|
45
|
-
npm install --save-
|
|
44
|
+
npm install --save @tsed/typegraphql type-graphql graphql@15
|
|
45
|
+
npm install --save apollo-datasource apollo-datasource-rest apollo-server-express
|
|
46
|
+
npm install --save-dev apollo-server-testing
|
|
46
47
|
```
|
|
47
48
|
|
|
48
49
|
Now, we can configure the Ts.ED server by importing `@tsed/typegraphql` in your Server:
|
|
@@ -63,7 +64,7 @@ export class Server {}
|
|
|
63
64
|
|
|
64
65
|
## TypeGraphQlService
|
|
65
66
|
|
|
66
|
-
TypeGraphQlService let you retrieve an instance of ApolloServer.
|
|
67
|
+
TypeGraphQlService let you to retrieve an instance of ApolloServer.
|
|
67
68
|
|
|
68
69
|
```typescript
|
|
69
70
|
import {Service, AfterRoutesInit} from "@tsed/common";
|
|
@@ -83,7 +84,7 @@ export class UsersService implements AfterRoutesInit {
|
|
|
83
84
|
}
|
|
84
85
|
```
|
|
85
86
|
|
|
86
|
-
For more information about ApolloServer look his documentation [here](https://www.apollographql.com/);
|
|
87
|
+
For more information about ApolloServer look his documentation [here](https://www.apollographql.com/docs/apollo-server/api/apollo-server.html);
|
|
87
88
|
|
|
88
89
|
## Type-graphql
|
|
89
90
|
|