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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,17 +1,16 @@
1
1
  {
2
2
  "name": "@tsed/typegraphql",
3
3
  "description": "TypeGraphQL package for Ts.ED framework, based on Apollo-server-core and Type-graphql",
4
- "type": "commonjs",
5
- "version": "8.0.0-alpha.5",
4
+ "type": "module",
5
+ "version": "8.0.0-alpha.6",
6
6
  "source": "./src/index.ts",
7
- "main": "./lib/cjs/index.js",
7
+ "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
9
9
  "typings": "./lib/types/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
12
  "types": "./lib/types/index.d.ts",
13
13
  "import": "./lib/esm/index.js",
14
- "require": "./lib/cjs/index.js",
15
14
  "default": "./lib/cjs/index.js"
16
15
  }
17
16
  },
@@ -25,16 +24,16 @@
25
24
  "test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
26
25
  },
27
26
  "dependencies": {
28
- "@tsed/apollo": "8.0.0-alpha.5",
27
+ "@tsed/apollo": "8.0.0-alpha.6",
29
28
  "tslib": "2.6.1"
30
29
  },
31
30
  "devDependencies": {
32
31
  "@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",
32
+ "@tsed/barrels": "8.0.0-alpha.6",
33
+ "@tsed/common": "8.0.0-alpha.6",
34
+ "@tsed/core": "8.0.0-alpha.6",
35
+ "@tsed/platform-express": "8.0.0-alpha.6",
36
+ "@tsed/typescript": "8.0.0-alpha.6",
38
37
  "@types/graphql": "^14.5.0",
39
38
  "class-validator": "~0.14.1",
40
39
  "cross-env": "^7.0.3",
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TypeGraphQLModule = void 0;
4
- const tslib_1 = require("tslib");
5
- const core_1 = require("@tsed/core");
6
- const di_1 = require("@tsed/di");
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");
11
- /**
12
- * @ignore
13
- */
14
- let TypeGraphQLModule = class TypeGraphQLModule {
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;
25
- }
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);
48
- }
49
- };
50
- tslib_1.__decorate([
51
- (0, di_1.Inject)(),
52
- tslib_1.__metadata("design:type", di_1.InjectorService)
53
- ], TypeGraphQLModule.prototype, "injector", void 0);
54
- tslib_1.__decorate([
55
- (0, di_1.Configuration)(),
56
- tslib_1.__metadata("design:type", Object)
57
- ], TypeGraphQLModule.prototype, "configuration", void 0);
58
- TypeGraphQLModule = tslib_1.__decorate([
59
- (0, di_1.Module)()
60
- ], TypeGraphQLModule);
61
- exports.TypeGraphQLModule = TypeGraphQLModule;
62
- //# sourceMappingURL=TypeGraphQLModule.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TypeGraphQLModule.js","sourceRoot":"","sources":["../../src/TypeGraphQLModule.ts"],"names":[],"mappings":";;;;AACA,qCAAyC;AACzC,iCAAwE;AACxE,+CAAyC;AACzC,2DAA6D;AAC7D,sCAAoC;AACpC,6EAAqE;AAErE;;GAEG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAO5B,KAAK,CAAC,oBAAoB,CAAC,QAA8B;QACvD,MAAM,EAAC,SAAS,EAAE,gBAAgB,GAAG,EAAE,EAAE,kBAAkB,GAAG,EAAE,EAAE,GAAG,aAAa,EAAC,GAAG,QAAQ,CAAC;QAE/F,MAAM,SAAS,GAAQ,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,GAAI,gBAA0B,EAAE,GAAG,CAAC,kBAAkB,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAEjI,aAAa,CAAC,MAAM,GAAG,MAAM,IAAA,0BAAW,EAAC;YACvC,SAAS,EAAE,IAAI,CAAC,QAAiB;YACjC,GAAG,kBAAkB;YACrB,SAAS;YACT,iBAAiB,EAAE,CAAC,wCAAiB,EAAE,GAAG,CAAC,kBAAkB,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;SACxF,CAAC,CAAC;QAEH,OAAO,aAAa,CAAC;IACvB,CAAC;IAES,YAAY,CAAC,EAAU,EAAE,SAAsB;QACvD,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ;aAClC,YAAY,CAAC,kCAAmB,CAAC;aACjC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE;YACnB,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAE3C,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,IAAI,EAAE,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,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,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RESOLVERS_PROVIDERS = void 0;
4
- exports.RESOLVERS_PROVIDERS = "graphql:resolvers";
5
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,mBAAmB,CAAC"}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ResolverController = void 0;
4
- const core_1 = require("@tsed/core");
5
- const di_1 = require("@tsed/di");
6
- const type_graphql_1 = require("type-graphql");
7
- const constants_js_1 = require("../constants/constants.js");
8
- function ResolverController(...args) {
9
- let id = undefined;
10
- switch (args.length) {
11
- case 1:
12
- if (typeof args[0] === "string") {
13
- id = args[0];
14
- }
15
- else {
16
- id = args[0].id;
17
- delete args[0].id;
18
- }
19
- break;
20
- case 2:
21
- id = args[1].id;
22
- delete args[1].id;
23
- break;
24
- }
25
- return (0, core_1.useDecorators)(type_graphql_1.Resolver(...args), (0, di_1.Injectable)({
26
- type: constants_js_1.RESOLVERS_PROVIDERS
27
- }), (0, core_1.StoreSet)("graphql", {
28
- id
29
- }));
30
- }
31
- exports.ResolverController = ResolverController;
32
- //# sourceMappingURL=resolver.js.map
@@ -1 +0,0 @@
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"}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DataSourceService = exports.DataSource = void 0;
4
- var apollo_1 = require("@tsed/apollo");
5
- Object.defineProperty(exports, "DataSource", { enumerable: true, get: function () { return apollo_1.DataSource; } });
6
- Object.defineProperty(exports, "DataSourceService", { enumerable: true, get: function () { return apollo_1.DataSourceService; } });
7
- //# sourceMappingURL=exports.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":";;;AAAA,uCAA2D;AAAnD,oGAAA,UAAU,OAAA;AAAE,2GAAA,iBAAiB,OAAA"}
package/lib/cjs/index.js DELETED
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- /**
5
- * @file Automatically generated by @tsed/barrels.
6
- */
7
- tslib_1.__exportStar(require("./constants/constants.js"), exports);
8
- tslib_1.__exportStar(require("./decorators/resolver.js"), exports);
9
- tslib_1.__exportStar(require("./exports.js"), exports);
10
- tslib_1.__exportStar(require("./interfaces/interfaces.js"), exports);
11
- tslib_1.__exportStar(require("./interfaces/TypeGraphQLSettings.js"), exports);
12
- tslib_1.__exportStar(require("./middlewares/ContextMiddleware.js"), exports);
13
- tslib_1.__exportStar(require("./TypeGraphQLModule.js"), exports);
14
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=TypeGraphQLSettings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TypeGraphQLSettings.js","sourceRoot":"","sources":["../../../src/interfaces/TypeGraphQLSettings.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=interfaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":""}
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ContextMiddleware = void 0;
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);
8
- };
9
- exports.ContextMiddleware = ContextMiddleware;
10
- //# sourceMappingURL=ContextMiddleware.js.map
@@ -1 +0,0 @@
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,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
@@ -1,13 +0,0 @@
1
- import { AlterApolloSettings, ApolloSettingsWithID } from "@tsed/apollo";
2
- import { Type } from "@tsed/core";
3
- import { Configuration, InjectorService } from "@tsed/di";
4
- import "./interfaces/interfaces.js";
5
- /**
6
- * @ignore
7
- */
8
- export declare class TypeGraphQLModule implements AlterApolloSettings {
9
- protected injector: InjectorService;
10
- protected configuration: Configuration;
11
- $alterApolloSettings(settings: ApolloSettingsWithID): Promise<ApolloSettingsWithID>;
12
- protected getResolvers(id: string, resolvers: Type<any>[]): Type<any>[];
13
- }
@@ -1 +0,0 @@
1
- export declare const RESOLVERS_PROVIDERS = "graphql:resolvers";
@@ -1,8 +0,0 @@
1
- import { ClassType } from "type-graphql";
2
- export interface ResolverControllerOptions {
3
- id?: string;
4
- }
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;
8
- export declare function ResolverController(objectType: ClassType, options?: ResolverControllerOptions): ClassDecorator;
@@ -1 +0,0 @@
1
- export { DataSource, DataSourceService } from "@tsed/apollo";
@@ -1,10 +0,0 @@
1
- /**
2
- * @file Automatically generated by @tsed/barrels.
3
- */
4
- export * from "./constants/constants.js";
5
- export * from "./decorators/resolver.js";
6
- export * from "./exports.js";
7
- export * from "./interfaces/interfaces.js";
8
- export * from "./interfaces/TypeGraphQLSettings.js";
9
- export * from "./middlewares/ContextMiddleware.js";
10
- export * from "./TypeGraphQLModule.js";
@@ -1 +0,0 @@
1
- export {};
@@ -1,23 +0,0 @@
1
- import { BuildSchemaOptions } from "type-graphql";
2
- import type { ApolloSettings as AS } from "@tsed/apollo";
3
- declare global {
4
- namespace TsED {
5
- interface ApolloSettings {
6
- buildSchemaOptions?: Partial<BuildSchemaOptions>;
7
- }
8
- interface Configuration {
9
- /**
10
- * @deprecated Use apollo instead
11
- */
12
- graphql: {
13
- [key: string]: AS;
14
- };
15
- /**
16
- * @deprecated Use apollo instead
17
- */
18
- typegraphql: {
19
- [key: string]: AS;
20
- };
21
- }
22
- }
23
- }
@@ -1,7 +0,0 @@
1
- import { type DIContext } from "@tsed/di";
2
- import { MiddlewareFn } from "type-graphql";
3
- export declare const ContextMiddleware: MiddlewareFn<{
4
- req: {
5
- $ctx: DIContext;
6
- };
7
- }>;