@tsed/typegraphql 8.0.0-alpha.4 → 8.0.0-alpha.5
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/lib/cjs/TypeGraphQLModule.js +37 -29
- package/lib/cjs/TypeGraphQLModule.js.map +1 -1
- package/lib/cjs/decorators/resolver.js +1 -8
- package/lib/cjs/decorators/resolver.js.map +1 -1
- package/lib/cjs/index.js +0 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces/interfaces.js +0 -2
- package/lib/cjs/interfaces/interfaces.js.map +1 -1
- package/lib/cjs/middlewares/ContextMiddleware.js +4 -3
- package/lib/cjs/middlewares/ContextMiddleware.js.map +1 -1
- package/lib/esm/TypeGraphQLModule.js +37 -29
- package/lib/esm/TypeGraphQLModule.js.map +1 -1
- package/lib/esm/decorators/resolver.js +0 -6
- package/lib/esm/decorators/resolver.js.map +1 -1
- package/lib/esm/index.js +0 -1
- 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/middlewares/ContextMiddleware.js +4 -3
- package/lib/esm/middlewares/ContextMiddleware.js.map +1 -1
- package/lib/types/TypeGraphQLModule.d.ts +6 -9
- package/lib/types/decorators/resolver.d.ts +4 -12
- package/lib/types/index.d.ts +0 -1
- package/lib/types/interfaces/TypeGraphQLSettings.d.ts +1 -6
- package/lib/types/interfaces/interfaces.d.ts +13 -4
- package/lib/types/middlewares/ContextMiddleware.d.ts +2 -2
- package/lib/types-esm/TypeGraphQLModule.d.ts +6 -9
- package/lib/types-esm/decorators/resolver.d.ts +4 -12
- package/lib/types-esm/index.d.ts +0 -1
- package/lib/types-esm/interfaces/TypeGraphQLSettings.d.ts +1 -6
- package/lib/types-esm/interfaces/interfaces.d.ts +13 -4
- package/lib/types-esm/middlewares/ContextMiddleware.d.ts +2 -2
- package/package.json +17 -12
- package/readme.md +31 -31
- package/vitest.config.mts +3 -3
- package/.nycrc +0 -27
- package/lib/cjs/services/TypeGraphQLService.js +0 -121
- package/lib/cjs/services/TypeGraphQLService.js.map +0 -1
- package/lib/esm/services/TypeGraphQLService.js +0 -118
- package/lib/esm/services/TypeGraphQLService.js.map +0 -1
- package/lib/types/services/TypeGraphQLService.d.ts +0 -36
- package/lib/types-esm/services/TypeGraphQLService.d.ts +0 -36
|
@@ -2,43 +2,51 @@
|
|
|
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");
|
|
5
6
|
const di_1 = require("@tsed/di");
|
|
6
|
-
const
|
|
7
|
+
const type_graphql_1 = require("type-graphql");
|
|
8
|
+
const constants_js_1 = require("./constants/constants.js");
|
|
9
|
+
require("./interfaces/interfaces.js");
|
|
10
|
+
const ContextMiddleware_js_1 = require("./middlewares/ContextMiddleware.js");
|
|
7
11
|
/**
|
|
8
12
|
* @ignore
|
|
9
13
|
*/
|
|
10
14
|
let TypeGraphQLModule = class TypeGraphQLModule {
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
async $alterApolloSettings(settings) {
|
|
16
|
+
const { resolvers: initialResolvers = [], buildSchemaOptions = {}, ...serverOptions } = settings;
|
|
17
|
+
const resolvers = this.getResolvers(settings.id, [...initialResolvers, ...(buildSchemaOptions.resolvers || [])]);
|
|
18
|
+
serverOptions.schema = await (0, type_graphql_1.buildSchema)({
|
|
19
|
+
container: this.injector,
|
|
20
|
+
...buildSchemaOptions,
|
|
21
|
+
resolvers,
|
|
22
|
+
globalMiddlewares: [ContextMiddleware_js_1.ContextMiddleware, ...(buildSchemaOptions.globalMiddlewares || [])]
|
|
23
|
+
});
|
|
24
|
+
return serverOptions;
|
|
13
25
|
}
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
getResolvers(id, resolvers) {
|
|
27
|
+
const globalResolvers = this.injector
|
|
28
|
+
.getProviders(constants_js_1.RESOLVERS_PROVIDERS)
|
|
29
|
+
.filter((provider) => {
|
|
30
|
+
const opts = provider.store.get("graphql");
|
|
31
|
+
return !opts?.id || opts?.id === id;
|
|
32
|
+
})
|
|
33
|
+
.map((provider) => {
|
|
34
|
+
return provider.useClass;
|
|
35
|
+
});
|
|
36
|
+
return resolvers
|
|
37
|
+
.map((resolver) => {
|
|
38
|
+
if (!(this.injector.has(resolver) || !(0, core_1.isClass)(resolver))) {
|
|
39
|
+
this.injector
|
|
40
|
+
.addProvider(resolver, {
|
|
41
|
+
useClass: resolver
|
|
42
|
+
})
|
|
43
|
+
.invoke(resolver);
|
|
44
|
+
}
|
|
45
|
+
return resolver;
|
|
46
|
+
})
|
|
47
|
+
.concat(globalResolvers);
|
|
36
48
|
}
|
|
37
49
|
};
|
|
38
|
-
tslib_1.__decorate([
|
|
39
|
-
(0, di_1.Inject)(),
|
|
40
|
-
tslib_1.__metadata("design:type", TypeGraphQLService_js_1.TypeGraphQLService)
|
|
41
|
-
], TypeGraphQLModule.prototype, "service", void 0);
|
|
42
50
|
tslib_1.__decorate([
|
|
43
51
|
(0, di_1.Inject)(),
|
|
44
52
|
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":";;;;AACA,qCAA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AE,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;AA/CC;IAAC,IAAA,WAAM,GAAE;sCACW,oBAAe;mDAAC;AAEpC;IAAC,IAAA,kBAAa,GAAE;;wDACuB;AAL5B,iBAAiB;IAD7B,IAAA,WAAM,GAAE;GACI,iBAAiB,CAgD7B;AAhDY,8CAAiB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
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,11 +29,4 @@ 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;
|
|
39
32
|
//# 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;AACjD,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"}
|
package/lib/cjs/index.js
CHANGED
|
@@ -10,6 +10,5 @@ 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);
|
|
14
13
|
tslib_1.__exportStar(require("./TypeGraphQLModule.js"), exports);
|
|
15
14
|
//# 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,
|
|
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 +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":""}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ContextMiddleware = void 0;
|
|
4
|
-
const
|
|
5
|
-
const ContextMiddleware = (
|
|
6
|
-
|
|
4
|
+
const di_1 = require("@tsed/di");
|
|
5
|
+
const ContextMiddleware = (action, next) => {
|
|
6
|
+
const $ctx = (0, di_1.useContext)(action.context?.req?.$ctx);
|
|
7
|
+
return (0, di_1.runInContext)($ctx, next);
|
|
7
8
|
};
|
|
8
9
|
exports.ContextMiddleware = ContextMiddleware;
|
|
9
10
|
//# sourceMappingURL=ContextMiddleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/ContextMiddleware.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"ContextMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/ContextMiddleware.ts"],"names":[],"mappings":";;;AAAA,iCAAkE;AAG3D,MAAM,iBAAiB,GAA2C,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;IACxF,MAAM,IAAI,GAAG,IAAA,eAAU,EAAC,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IACnD,OAAO,IAAA,iBAAY,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAClC,CAAC,CAAC;AAHW,QAAA,iBAAiB,qBAG5B"}
|
|
@@ -1,41 +1,49 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { isClass } from "@tsed/core";
|
|
2
3
|
import { Configuration, Inject, InjectorService, Module } from "@tsed/di";
|
|
3
|
-
import {
|
|
4
|
+
import { buildSchema } from "type-graphql";
|
|
5
|
+
import { RESOLVERS_PROVIDERS } from "./constants/constants.js";
|
|
6
|
+
import "./interfaces/interfaces.js";
|
|
7
|
+
import { ContextMiddleware } from "./middlewares/ContextMiddleware.js";
|
|
4
8
|
/**
|
|
5
9
|
* @ignore
|
|
6
10
|
*/
|
|
7
11
|
let TypeGraphQLModule = class TypeGraphQLModule {
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
async $alterApolloSettings(settings) {
|
|
13
|
+
const { resolvers: initialResolvers = [], buildSchemaOptions = {}, ...serverOptions } = settings;
|
|
14
|
+
const resolvers = this.getResolvers(settings.id, [...initialResolvers, ...(buildSchemaOptions.resolvers || [])]);
|
|
15
|
+
serverOptions.schema = await buildSchema({
|
|
16
|
+
container: this.injector,
|
|
17
|
+
...buildSchemaOptions,
|
|
18
|
+
resolvers,
|
|
19
|
+
globalMiddlewares: [ContextMiddleware, ...(buildSchemaOptions.globalMiddlewares || [])]
|
|
20
|
+
});
|
|
21
|
+
return serverOptions;
|
|
10
22
|
}
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
getResolvers(id, resolvers) {
|
|
24
|
+
const globalResolvers = this.injector
|
|
25
|
+
.getProviders(RESOLVERS_PROVIDERS)
|
|
26
|
+
.filter((provider) => {
|
|
27
|
+
const opts = provider.store.get("graphql");
|
|
28
|
+
return !opts?.id || opts?.id === id;
|
|
29
|
+
})
|
|
30
|
+
.map((provider) => {
|
|
31
|
+
return provider.useClass;
|
|
32
|
+
});
|
|
33
|
+
return resolvers
|
|
34
|
+
.map((resolver) => {
|
|
35
|
+
if (!(this.injector.has(resolver) || !isClass(resolver))) {
|
|
36
|
+
this.injector
|
|
37
|
+
.addProvider(resolver, {
|
|
38
|
+
useClass: resolver
|
|
39
|
+
})
|
|
40
|
+
.invoke(resolver);
|
|
41
|
+
}
|
|
42
|
+
return resolver;
|
|
43
|
+
})
|
|
44
|
+
.concat(globalResolvers);
|
|
33
45
|
}
|
|
34
46
|
};
|
|
35
|
-
__decorate([
|
|
36
|
-
Inject(),
|
|
37
|
-
__metadata("design:type", TypeGraphQLService)
|
|
38
|
-
], TypeGraphQLModule.prototype, "service", void 0);
|
|
39
47
|
__decorate([
|
|
40
48
|
Inject(),
|
|
41
49
|
__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":";AACA,OAAO,EAAC,OAAO,EAAO,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,aAAa,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;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;AA/CC;IAAC,MAAM,EAAE;8BACW,eAAe;mDAAC;AAEpC;IAAC,aAAa,EAAE;;wDACuB;AAL5B,iBAAiB;IAD7B,MAAM,EAAE;GACI,iBAAiB,CAgD7B;SAhDY,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../src/decorators/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACnD,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAY,QAAQ,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../src/decorators/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACnD,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAY,QAAQ,EAAC,MAAM,cAAc,CAAC;AACjD,OAAO,EAAC,mBAAmB,EAAC,MAAM,2BAA2B,CAAC;AAU9D,MAAM,UAAU,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,aAAa,CACjB,QAAgB,CAAC,GAAG,IAAI,CAAC,EAC1B,UAAU,CAAC;QACT,IAAI,EAAE,mBAAmB;KAC1B,CAAC,EACF,QAAQ,CAAC,SAAS,EAAE;QAClB,EAAE;KACH,CAAC,CACH,CAAC;AACJ,CAAC"}
|
package/lib/esm/index.js
CHANGED
|
@@ -7,6 +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";
|
|
11
10
|
export * from "./TypeGraphQLModule.js";
|
|
12
11
|
//# 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,
|
|
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,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|
|
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":""}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const ContextMiddleware = (
|
|
3
|
-
|
|
1
|
+
import { runInContext, useContext } from "@tsed/di";
|
|
2
|
+
export const ContextMiddleware = (action, next) => {
|
|
3
|
+
const $ctx = useContext(action.context?.req?.$ctx);
|
|
4
|
+
return runInContext($ctx, next);
|
|
4
5
|
};
|
|
5
6
|
//# sourceMappingURL=ContextMiddleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/ContextMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ContextMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/ContextMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,YAAY,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAGlE,MAAM,CAAC,MAAM,iBAAiB,GAA2C,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;IACxF,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IACnD,OAAO,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAClC,CAAC,CAAC"}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
+
import { AlterApolloSettings, ApolloSettingsWithID } from "@tsed/apollo";
|
|
2
|
+
import { Type } from "@tsed/core";
|
|
1
3
|
import { Configuration, InjectorService } from "@tsed/di";
|
|
2
|
-
import
|
|
3
|
-
import { TypeGraphQLService } from "./services/TypeGraphQLService.js";
|
|
4
|
+
import "./interfaces/interfaces.js";
|
|
4
5
|
/**
|
|
5
6
|
* @ignore
|
|
6
7
|
*/
|
|
7
|
-
export declare class TypeGraphQLModule {
|
|
8
|
-
protected service: TypeGraphQLService;
|
|
8
|
+
export declare class TypeGraphQLModule implements AlterApolloSettings {
|
|
9
9
|
protected injector: InjectorService;
|
|
10
10
|
protected configuration: Configuration;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} | undefined;
|
|
14
|
-
$onRoutesInit(): Promise<any> | void;
|
|
15
|
-
$afterListen(): Promise<any> | void;
|
|
11
|
+
$alterApolloSettings(settings: ApolloSettingsWithID): Promise<ApolloSettingsWithID>;
|
|
12
|
+
protected getResolvers(id: string, resolvers: Type<any>[]): Type<any>[];
|
|
16
13
|
}
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import { ClassType } from "type-graphql";
|
|
2
|
-
|
|
3
|
-
export interface ResolverControllerOptions extends AbstractClassOptions {
|
|
2
|
+
export interface ResolverControllerOptions {
|
|
4
3
|
id?: string;
|
|
5
4
|
}
|
|
6
|
-
export declare function ResolverController(
|
|
7
|
-
export declare function ResolverController(
|
|
8
|
-
export declare function ResolverController(typeFunc:
|
|
5
|
+
export declare function ResolverController(): ClassDecorator;
|
|
6
|
+
export declare function ResolverController(path: string): ClassDecorator;
|
|
7
|
+
export declare function ResolverController(typeFunc: (of?: void) => ClassType | Function, options?: ResolverControllerOptions): ClassDecorator;
|
|
9
8
|
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,5 +7,4 @@ 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";
|
|
11
10
|
export * from "./TypeGraphQLModule.js";
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { BuildSchemaOptions } from "type-graphql";
|
|
3
|
-
export interface TypeGraphQLSettings extends ApolloSettings {
|
|
4
|
-
buildSchemaOptions?: Partial<BuildSchemaOptions>;
|
|
5
|
-
serverConfig?: ApolloConfig;
|
|
6
|
-
}
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BuildSchemaOptions } from "type-graphql";
|
|
2
|
+
import type { ApolloSettings as AS } from "@tsed/apollo";
|
|
2
3
|
declare global {
|
|
3
4
|
namespace TsED {
|
|
5
|
+
interface ApolloSettings {
|
|
6
|
+
buildSchemaOptions?: Partial<BuildSchemaOptions>;
|
|
7
|
+
}
|
|
4
8
|
interface Configuration {
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use apollo instead
|
|
11
|
+
*/
|
|
5
12
|
graphql: {
|
|
6
|
-
[key: string]:
|
|
13
|
+
[key: string]: AS;
|
|
7
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use apollo instead
|
|
17
|
+
*/
|
|
8
18
|
typegraphql: {
|
|
9
|
-
[key: string]:
|
|
19
|
+
[key: string]: AS;
|
|
10
20
|
};
|
|
11
21
|
}
|
|
12
22
|
}
|
|
13
23
|
}
|
|
14
|
-
export * from "./TypeGraphQLSettings.js";
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
+
import { AlterApolloSettings, ApolloSettingsWithID } from "@tsed/apollo";
|
|
2
|
+
import { Type } from "@tsed/core";
|
|
1
3
|
import { Configuration, InjectorService } from "@tsed/di";
|
|
2
|
-
import
|
|
3
|
-
import { TypeGraphQLService } from "./services/TypeGraphQLService.js";
|
|
4
|
+
import "./interfaces/interfaces.js";
|
|
4
5
|
/**
|
|
5
6
|
* @ignore
|
|
6
7
|
*/
|
|
7
|
-
export declare class TypeGraphQLModule {
|
|
8
|
-
protected service: TypeGraphQLService;
|
|
8
|
+
export declare class TypeGraphQLModule implements AlterApolloSettings {
|
|
9
9
|
protected injector: InjectorService;
|
|
10
10
|
protected configuration: Configuration;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} | undefined;
|
|
14
|
-
$onRoutesInit(): Promise<any> | void;
|
|
15
|
-
$afterListen(): Promise<any> | void;
|
|
11
|
+
$alterApolloSettings(settings: ApolloSettingsWithID): Promise<ApolloSettingsWithID>;
|
|
12
|
+
protected getResolvers(id: string, resolvers: Type<any>[]): Type<any>[];
|
|
16
13
|
}
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import { ClassType } from "type-graphql";
|
|
2
|
-
|
|
3
|
-
export interface ResolverControllerOptions extends AbstractClassOptions {
|
|
2
|
+
export interface ResolverControllerOptions {
|
|
4
3
|
id?: string;
|
|
5
4
|
}
|
|
6
|
-
export declare function ResolverController(
|
|
7
|
-
export declare function ResolverController(
|
|
8
|
-
export declare function ResolverController(typeFunc:
|
|
5
|
+
export declare function ResolverController(): ClassDecorator;
|
|
6
|
+
export declare function ResolverController(path: string): ClassDecorator;
|
|
7
|
+
export declare function ResolverController(typeFunc: (of?: void) => ClassType | Function, options?: ResolverControllerOptions): ClassDecorator;
|
|
9
8
|
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,5 +7,4 @@ 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";
|
|
11
10
|
export * from "./TypeGraphQLModule.js";
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { BuildSchemaOptions } from "type-graphql";
|
|
3
|
-
export interface TypeGraphQLSettings extends ApolloSettings {
|
|
4
|
-
buildSchemaOptions?: Partial<BuildSchemaOptions>;
|
|
5
|
-
serverConfig?: ApolloConfig;
|
|
6
|
-
}
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BuildSchemaOptions } from "type-graphql";
|
|
2
|
+
import type { ApolloSettings as AS } from "@tsed/apollo";
|
|
2
3
|
declare global {
|
|
3
4
|
namespace TsED {
|
|
5
|
+
interface ApolloSettings {
|
|
6
|
+
buildSchemaOptions?: Partial<BuildSchemaOptions>;
|
|
7
|
+
}
|
|
4
8
|
interface Configuration {
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use apollo instead
|
|
11
|
+
*/
|
|
5
12
|
graphql: {
|
|
6
|
-
[key: string]:
|
|
13
|
+
[key: string]: AS;
|
|
7
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use apollo instead
|
|
17
|
+
*/
|
|
8
18
|
typegraphql: {
|
|
9
|
-
[key: string]:
|
|
19
|
+
[key: string]: AS;
|
|
10
20
|
};
|
|
11
21
|
}
|
|
12
22
|
}
|
|
13
23
|
}
|
|
14
|
-
export * from "./TypeGraphQLSettings.js";
|
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": "8.0.0-alpha.
|
|
5
|
+
"version": "8.0.0-alpha.5",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/cjs/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
@@ -25,29 +25,34 @@
|
|
|
25
25
|
"test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@tsed/apollo": "8.0.0-alpha.
|
|
28
|
+
"@tsed/apollo": "8.0.0-alpha.5",
|
|
29
29
|
"tslib": "2.6.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@
|
|
33
|
-
"@tsed/
|
|
34
|
-
"@tsed/
|
|
35
|
-
"@tsed/
|
|
32
|
+
"@graphql-yoga/subscription": "5.0.0",
|
|
33
|
+
"@tsed/barrels": "8.0.0-alpha.5",
|
|
34
|
+
"@tsed/common": "8.0.0-alpha.5",
|
|
35
|
+
"@tsed/core": "8.0.0-alpha.5",
|
|
36
|
+
"@tsed/platform-express": "8.0.0-alpha.5",
|
|
37
|
+
"@tsed/typescript": "8.0.0-alpha.5",
|
|
36
38
|
"@types/graphql": "^14.5.0",
|
|
37
39
|
"class-validator": "~0.14.1",
|
|
38
40
|
"cross-env": "^7.0.3",
|
|
39
41
|
"eslint": "^8.57.0",
|
|
40
|
-
"graphql
|
|
41
|
-
"
|
|
42
|
+
"graphql": "16.8.2",
|
|
43
|
+
"graphql-passport": "^0.6.8",
|
|
44
|
+
"graphql-scalars": "1.23.0",
|
|
45
|
+
"ts-node": "10.9.2",
|
|
46
|
+
"type-graphql": ">=2.0.0-rc.2",
|
|
42
47
|
"typescript": "4.9.5",
|
|
43
48
|
"vitest": "2.0.4"
|
|
44
49
|
},
|
|
45
50
|
"peerDependencies": {
|
|
46
|
-
"apollo-
|
|
47
|
-
"apollo-datasource-rest": ">=3.0.0",
|
|
51
|
+
"@apollo/datasource-rest": ">=6.2.2",
|
|
48
52
|
"class-validator": ">=0.13.1",
|
|
49
|
-
"graphql": ">=
|
|
50
|
-
"
|
|
53
|
+
"graphql": ">=16.0.0",
|
|
54
|
+
"graphql-scalars": ">=1.23.0",
|
|
55
|
+
"type-graphql": ">=2.0.0-rc.2"
|
|
51
56
|
},
|
|
52
57
|
"repository": "https://github.com/tsedio/tsed",
|
|
53
58
|
"bugs": {
|
package/readme.md
CHANGED
|
@@ -33,59 +33,59 @@ 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`](https://www.apollographql.com/) to create GraphQL server and [`type-graphql`](https://19majkel94.github.io/type-graphql/)
|
|
37
37
|
for the decorators.
|
|
38
38
|
|
|
39
39
|
## Installation
|
|
40
40
|
|
|
41
41
|
To begin, install the TypeGraphQL module for TS.ED:
|
|
42
42
|
|
|
43
|
+
Express.js:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install --save @tsed/apollo graphql type-graphql @apollo/server @apollo/datasource-rest graphql-scalars
|
|
47
|
+
npm install --save-dev apollo-server-testing
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Koa.js
|
|
51
|
+
|
|
43
52
|
```bash
|
|
44
|
-
npm install --save @tsed/
|
|
45
|
-
npm install --save
|
|
46
|
-
npm install --save-dev apollo-server-testing
|
|
53
|
+
npm install --save @tsed/apollo graphql type-graphql @apollo/server @as-integration/koa @apollo/datasource-rest graphql-scalars
|
|
54
|
+
npm install --save-dev apollo-server-testing
|
|
47
55
|
```
|
|
48
56
|
|
|
49
57
|
Now, we can configure the Ts.ED server by importing `@tsed/typegraphql` in your Server:
|
|
50
58
|
|
|
51
59
|
```typescript
|
|
52
|
-
import {Configuration} from "@tsed/
|
|
60
|
+
import {Configuration} from "@tsed/di";
|
|
61
|
+
import "@tsed/platform-express";
|
|
53
62
|
import "@tsed/typegraphql";
|
|
63
|
+
import "./resolvers/index"; // barrel file with all resolvers
|
|
54
64
|
|
|
55
65
|
@Configuration({
|
|
56
|
-
|
|
66
|
+
apollo: {
|
|
57
67
|
server1: {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
export class Server {}
|
|
63
|
-
```
|
|
68
|
+
// GraphQL server configuration
|
|
69
|
+
// See options descriptions on https://www.apollographql.com/docs/apollo-server/api/apollo-server.html
|
|
70
|
+
path: "/",
|
|
71
|
+
playground: true // enable playground GraphQL IDE. Set false to use Apollo Studio
|
|
64
72
|
|
|
65
|
-
|
|
73
|
+
// resolvers?: (Function | string)[];
|
|
74
|
+
// dataSources?: Function;
|
|
75
|
+
// server?: (config: Config) => ApolloServer;
|
|
66
76
|
|
|
67
|
-
|
|
77
|
+
// plugins: []
|
|
78
|
+
// middlewareOptions?: ServerRegistration;
|
|
68
79
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
@Service()
|
|
75
|
-
export class UsersService implements AfterRoutesInit {
|
|
76
|
-
private server: ApolloServer;
|
|
77
|
-
|
|
78
|
-
@Inject()
|
|
79
|
-
typeGraphQLService: TypeGraphQLService;
|
|
80
|
-
|
|
81
|
-
$afterRoutesInit() {
|
|
82
|
-
this.server = this.typeGraphQLService.get("server1");
|
|
80
|
+
// type-graphql
|
|
81
|
+
// See options descriptions on https://19majkel94.github.io/type-graphql/
|
|
82
|
+
// buildSchemaOptions?: Partial<BuildSchemaOptions>;
|
|
83
|
+
}
|
|
83
84
|
}
|
|
84
|
-
}
|
|
85
|
+
})
|
|
86
|
+
export class Server {}
|
|
85
87
|
```
|
|
86
88
|
|
|
87
|
-
For more information about ApolloServer look his documentation [here](https://www.apollographql.com/docs/apollo-server/api/apollo-server.html);
|
|
88
|
-
|
|
89
89
|
## Type-graphql
|
|
90
90
|
|
|
91
91
|
### Types
|
package/vitest.config.mts
CHANGED
package/.nycrc
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
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
|
-
/**
|
|
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_js_1.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 (0, type_graphql_1.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(constants_js_1.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) || !(0, core_1.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
|
-
tslib_1.__decorate([
|
|
106
|
-
(0, di_1.Inject)(),
|
|
107
|
-
tslib_1.__metadata("design:type", di_1.InjectorService)
|
|
108
|
-
], TypeGraphQLService.prototype, "injector", void 0);
|
|
109
|
-
tslib_1.__decorate([
|
|
110
|
-
(0, di_1.Inject)(),
|
|
111
|
-
tslib_1.__metadata("design:type", apollo_1.ApolloService)
|
|
112
|
-
], TypeGraphQLService.prototype, "apolloService", void 0);
|
|
113
|
-
tslib_1.__decorate([
|
|
114
|
-
(0, di_1.Inject)(),
|
|
115
|
-
tslib_1.__metadata("design:type", logger_1.Logger)
|
|
116
|
-
], TypeGraphQLService.prototype, "logger", void 0);
|
|
117
|
-
TypeGraphQLService = tslib_1.__decorate([
|
|
118
|
-
(0, di_1.Injectable)()
|
|
119
|
-
], TypeGraphQLService);
|
|
120
|
-
exports.TypeGraphQLService = TypeGraphQLService;
|
|
121
|
-
//# sourceMappingURL=TypeGraphQLService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,EAAE,CAAC;AAG5C,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAU7B;;;OAGG;IACH,GAAG,CAAC,KAAa,SAAS;QACxB,OAAO,IAAI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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,118 +0,0 @@
|
|
|
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
|
-
/**
|
|
12
|
-
* Get an instance of ApolloServer from his id
|
|
13
|
-
* @returns ApolloServer
|
|
14
|
-
*/
|
|
15
|
-
get(id = "default") {
|
|
16
|
-
return this.apolloService.get(getKey(id));
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param {string} id
|
|
21
|
-
* @returns {boolean}
|
|
22
|
-
*/
|
|
23
|
-
has(id = "default") {
|
|
24
|
-
return this.apolloService.has(getKey(id));
|
|
25
|
-
}
|
|
26
|
-
async createServer(id, settings) {
|
|
27
|
-
if (!this.has(id)) {
|
|
28
|
-
try {
|
|
29
|
-
const { dataSources, resolvers: initialResolvers = [], buildSchemaOptions = {}, serverConfig = {}, ...serverOptions } = settings;
|
|
30
|
-
const resolvers = this.getResolvers(id, [...initialResolvers, ...(buildSchemaOptions.resolvers || [])]);
|
|
31
|
-
const schema = await this.createSchema({
|
|
32
|
-
container: this.injector,
|
|
33
|
-
...buildSchemaOptions,
|
|
34
|
-
resolvers,
|
|
35
|
-
globalMiddlewares: [ContextMiddleware, ...(buildSchemaOptions.globalMiddlewares || [])]
|
|
36
|
-
});
|
|
37
|
-
return await this.apolloService.createServer(getKey(id), {
|
|
38
|
-
...serverOptions,
|
|
39
|
-
...serverConfig,
|
|
40
|
-
resolvers,
|
|
41
|
-
dataSources: () => {
|
|
42
|
-
return {
|
|
43
|
-
...(dataSources ? dataSources() : {}),
|
|
44
|
-
...(serverConfig.dataSources ? serverConfig.dataSources() : {})
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
schema
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
catch (er) {
|
|
51
|
-
/* istanbul ignore next */
|
|
52
|
-
this.logger.error({
|
|
53
|
-
event: "TYPEGRAPHQL_BOOTSTRAP_ERROR",
|
|
54
|
-
error_name: er.name,
|
|
55
|
-
message: er.message,
|
|
56
|
-
stack: er.stack
|
|
57
|
-
});
|
|
58
|
-
/* istanbul ignore next */
|
|
59
|
-
process.exit(-1);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return this.get(id);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Create a new type-graphql Schema and bind it with Ts.ED injector.
|
|
66
|
-
* @param buildSchemaOptions
|
|
67
|
-
*/
|
|
68
|
-
createSchema(buildSchemaOptions) {
|
|
69
|
-
return buildSchema(buildSchemaOptions);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Get an instance of GraphQL schema from his id
|
|
73
|
-
* @returns GraphQLSchema
|
|
74
|
-
*/
|
|
75
|
-
getSchema(id = "default") {
|
|
76
|
-
return this.apolloService.getSchema(getKey(id));
|
|
77
|
-
}
|
|
78
|
-
getResolvers(id, resolvers) {
|
|
79
|
-
const globalResolvers = this.injector
|
|
80
|
-
.getProviders(RESOLVERS_PROVIDERS)
|
|
81
|
-
.filter((provider) => {
|
|
82
|
-
const opts = provider.store.get("graphql");
|
|
83
|
-
return !opts?.id || opts?.id === id;
|
|
84
|
-
})
|
|
85
|
-
.map((provider) => {
|
|
86
|
-
return provider.useClass;
|
|
87
|
-
});
|
|
88
|
-
return resolvers
|
|
89
|
-
.map((resolver) => {
|
|
90
|
-
if (!(this.injector.has(resolver) || !isClass(resolver))) {
|
|
91
|
-
this.injector
|
|
92
|
-
.addProvider(resolver, {
|
|
93
|
-
useClass: resolver
|
|
94
|
-
})
|
|
95
|
-
.invoke(resolver);
|
|
96
|
-
}
|
|
97
|
-
return resolver;
|
|
98
|
-
})
|
|
99
|
-
.concat(globalResolvers);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
__decorate([
|
|
103
|
-
Inject(),
|
|
104
|
-
__metadata("design:type", InjectorService)
|
|
105
|
-
], TypeGraphQLService.prototype, "injector", void 0);
|
|
106
|
-
__decorate([
|
|
107
|
-
Inject(),
|
|
108
|
-
__metadata("design:type", ApolloService)
|
|
109
|
-
], TypeGraphQLService.prototype, "apolloService", void 0);
|
|
110
|
-
__decorate([
|
|
111
|
-
Inject(),
|
|
112
|
-
__metadata("design:type", Logger)
|
|
113
|
-
], TypeGraphQLService.prototype, "logger", void 0);
|
|
114
|
-
TypeGraphQLService = __decorate([
|
|
115
|
-
Injectable()
|
|
116
|
-
], TypeGraphQLService);
|
|
117
|
-
export { TypeGraphQLService };
|
|
118
|
-
//# sourceMappingURL=TypeGraphQLService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,EAAU,EAAE,EAAE,CAAC,eAAe,EAAE,EAAE,CAAC;AAG5C,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAU7B;;;OAGG;IACH,GAAG,CAAC,KAAa,SAAS;QACxB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,KAAa,SAAS;QACxB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,EAAU,EAAE,QAA6B;QAC1D,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YACjB,IAAI;gBACF,MAAM,EAAC,WAAW,EAAE,SAAS,EAAE,gBAAgB,GAAG,EAAE,EAAE,kBAAkB,GAAG,EAAE,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,aAAa,EAAC,GAAG,QAAQ,CAAC;gBAE/H,MAAM,S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AD9B,UAAU,EAAE;GACA,kBAAkB,CA+G9B;SA/GY,kBAAkB"}
|
|
@@ -1,36 +0,0 @@
|
|
|
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,36 +0,0 @@
|
|
|
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
|
-
}
|