@tsed/typegraphql 8.37.0 → 8.38.0-beta.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.
@@ -1,6 +1,5 @@
1
- import { __decorate, __metadata } from "tslib";
2
1
  import "./interfaces/interfaces.js";
3
- import { Configuration, Inject, InjectorService, Module } from "@tsed/di";
2
+ import { injectable, injector } from "@tsed/di";
4
3
  import { isClass } from "@tsed/core";
5
4
  import { ContextMiddleware } from "./middlewares/ContextMiddleware.js";
6
5
  import { RESOLVERS_PROVIDERS } from "./constants/constants.js";
@@ -8,12 +7,12 @@ import { buildSchema } from "type-graphql";
8
7
  /**
9
8
  * @ignore
10
9
  */
11
- let TypeGraphQLModule = class TypeGraphQLModule {
10
+ export class TypeGraphQLModule {
12
11
  async $alterApolloSettings(settings) {
13
12
  const { resolvers: initialResolvers = [], buildSchemaOptions = {}, ...serverOptions } = settings;
14
13
  const resolvers = this.getResolvers(settings.id, [...initialResolvers, ...(buildSchemaOptions.resolvers || [])]);
15
14
  serverOptions.schema = await buildSchema({
16
- container: this.injector,
15
+ container: injector(),
17
16
  ...buildSchemaOptions,
18
17
  resolvers,
19
18
  globalMiddlewares: [ContextMiddleware, ...(buildSchemaOptions.globalMiddlewares || [])]
@@ -21,8 +20,8 @@ let TypeGraphQLModule = class TypeGraphQLModule {
21
20
  return serverOptions;
22
21
  }
23
22
  getResolvers(id, resolvers) {
24
- const globalResolvers = this.injector
25
- .getProviders(RESOLVERS_PROVIDERS)
23
+ const globalResolvers = injector()
24
+ .providers.getMany(RESOLVERS_PROVIDERS)
26
25
  .filter((provider) => {
27
26
  const opts = provider.store.get("graphql");
28
27
  return !opts?.id || opts?.id === id;
@@ -32,9 +31,9 @@ let TypeGraphQLModule = class TypeGraphQLModule {
32
31
  });
33
32
  return resolvers
34
33
  .map((resolver) => {
35
- if (!(this.injector.has(resolver) || !isClass(resolver))) {
36
- this.injector
37
- .addProvider(resolver, {
34
+ if (!(injector().has(resolver) || !isClass(resolver))) {
35
+ injector()
36
+ .add(resolver, {
38
37
  useClass: resolver
39
38
  })
40
39
  .invoke(resolver);
@@ -43,16 +42,5 @@ let TypeGraphQLModule = class TypeGraphQLModule {
43
42
  })
44
43
  .concat(globalResolvers);
45
44
  }
46
- };
47
- __decorate([
48
- Inject(),
49
- __metadata("design:type", InjectorService)
50
- ], TypeGraphQLModule.prototype, "injector", void 0);
51
- __decorate([
52
- Configuration(),
53
- __metadata("design:type", Object)
54
- ], TypeGraphQLModule.prototype, "configuration", void 0);
55
- TypeGraphQLModule = __decorate([
56
- Module()
57
- ], TypeGraphQLModule);
58
- export { TypeGraphQLModule };
45
+ }
46
+ injectable(TypeGraphQLModule);
@@ -1,13 +1,10 @@
1
1
  import "./interfaces/interfaces.js";
2
2
  import { AlterApolloSettings, ApolloSettingsWithID } from "@tsed/apollo";
3
- import { Configuration, InjectorService } from "@tsed/di";
4
3
  import { Type } from "@tsed/core";
5
4
  /**
6
5
  * @ignore
7
6
  */
8
7
  export declare class TypeGraphQLModule implements AlterApolloSettings {
9
- protected injector: InjectorService;
10
- protected configuration: Configuration;
11
8
  $alterApolloSettings(settings: ApolloSettingsWithID): Promise<ApolloSettingsWithID>;
12
9
  protected getResolvers(id: string, resolvers: Type<any>[]): Type<any>[];
13
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/typegraphql",
3
- "version": "8.37.0",
3
+ "version": "8.38.0-beta.1",
4
4
  "description": "TypeGraphQL package for Ts.ED framework, based on Apollo-server-core and Type-graphql",
5
5
  "source": "./src/index.ts",
6
6
  "type": "module",
@@ -25,16 +25,16 @@
25
25
  "test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
26
26
  },
27
27
  "dependencies": {
28
- "@tsed/apollo": "8.37.0",
28
+ "@tsed/apollo": "8.38.0-beta.1",
29
29
  "tslib": ">=2.7.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@graphql-yoga/subscription": "5.0.1",
33
- "@tsed/barrels": "8.37.0",
34
- "@tsed/core": "8.37.0",
35
- "@tsed/platform-express": "8.37.0",
36
- "@tsed/platform-http": "8.37.0",
37
- "@tsed/typescript": "8.37.0",
33
+ "@tsed/barrels": "8.38.0-beta.1",
34
+ "@tsed/core": "8.38.0-beta.1",
35
+ "@tsed/platform-express": "8.38.0-beta.1",
36
+ "@tsed/platform-http": "8.38.0-beta.1",
37
+ "@tsed/typescript": "8.38.0-beta.1",
38
38
  "class-validator": "~0.14.1",
39
39
  "cross-env": "^7.0.3",
40
40
  "graphql": "16.12.0",
@@ -58,5 +58,8 @@
58
58
  },
59
59
  "homepage": "https://github.com/tsedio/tsed/tree/production/packages/graphql/typegraphql",
60
60
  "author": "Romain Lenzotti",
61
- "license": "MIT"
61
+ "license": "MIT",
62
+ "publishConfig": {
63
+ "tag": "beta"
64
+ }
62
65
  }