@tsed/apollo 7.81.0-rc.1 → 7.81.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/.nycrc +26 -0
  2. package/lib/cjs/ApolloModule.js +7 -13
  3. package/lib/cjs/ApolloModule.js.map +1 -1
  4. package/lib/cjs/constants/constants.js +1 -2
  5. package/lib/cjs/constants/constants.js.map +1 -1
  6. package/lib/cjs/decorators/dataSource.js +2 -2
  7. package/lib/cjs/index.js +0 -5
  8. package/lib/cjs/index.js.map +1 -1
  9. package/lib/cjs/services/ApolloService.js +55 -72
  10. package/lib/cjs/services/ApolloService.js.map +1 -1
  11. package/lib/esm/ApolloModule.js +8 -14
  12. package/lib/esm/ApolloModule.js.map +1 -1
  13. package/lib/esm/constants/constants.js +0 -1
  14. package/lib/esm/constants/constants.js.map +1 -1
  15. package/lib/esm/decorators/dataSource.js +2 -2
  16. package/lib/esm/index.js +0 -5
  17. package/lib/esm/index.js.map +1 -1
  18. package/lib/esm/services/ApolloService.js +55 -72
  19. package/lib/esm/services/ApolloService.js.map +1 -1
  20. package/lib/types/ApolloModule.d.ts +2 -3
  21. package/lib/types/constants/constants.d.ts +0 -1
  22. package/lib/types/decorators/dataSource.d.ts +2 -2
  23. package/lib/types/index.d.ts +0 -5
  24. package/lib/types/interfaces/ApolloSettings.d.ts +10 -22
  25. package/lib/types/services/ApolloService.d.ts +14 -18
  26. package/lib/types-esm/ApolloModule.d.ts +2 -3
  27. package/lib/types-esm/constants/constants.d.ts +0 -1
  28. package/lib/types-esm/decorators/dataSource.d.ts +2 -2
  29. package/lib/types-esm/index.d.ts +0 -5
  30. package/lib/types-esm/interfaces/ApolloSettings.d.ts +10 -22
  31. package/lib/types-esm/services/ApolloService.d.ts +14 -18
  32. package/package.json +22 -23
  33. package/readme.md +24 -1
  34. package/vitest.config.mts +5 -5
  35. package/lib/cjs/decorators/injectApolloContext.js +0 -28
  36. package/lib/cjs/decorators/injectApolloContext.js.map +0 -1
  37. package/lib/cjs/interfaces/AlterApolloContext.js +0 -3
  38. package/lib/cjs/interfaces/AlterApolloContext.js.map +0 -1
  39. package/lib/cjs/interfaces/AlterApolloServerPlugins.js +0 -3
  40. package/lib/cjs/interfaces/AlterApolloServerPlugins.js.map +0 -1
  41. package/lib/cjs/interfaces/AlterApolloSettings.js +0 -3
  42. package/lib/cjs/interfaces/AlterApolloSettings.js.map +0 -1
  43. package/lib/cjs/interfaces/ApolloContext.js +0 -3
  44. package/lib/cjs/interfaces/ApolloContext.js.map +0 -1
  45. package/lib/esm/decorators/injectApolloContext.js +0 -24
  46. package/lib/esm/decorators/injectApolloContext.js.map +0 -1
  47. package/lib/esm/interfaces/AlterApolloContext.js +0 -2
  48. package/lib/esm/interfaces/AlterApolloContext.js.map +0 -1
  49. package/lib/esm/interfaces/AlterApolloServerPlugins.js +0 -2
  50. package/lib/esm/interfaces/AlterApolloServerPlugins.js.map +0 -1
  51. package/lib/esm/interfaces/AlterApolloSettings.js +0 -2
  52. package/lib/esm/interfaces/AlterApolloSettings.js.map +0 -1
  53. package/lib/esm/interfaces/ApolloContext.js +0 -2
  54. package/lib/esm/interfaces/ApolloContext.js.map +0 -1
  55. package/lib/types/decorators/injectApolloContext.d.ts +0 -5
  56. package/lib/types/interfaces/AlterApolloContext.d.ts +0 -5
  57. package/lib/types/interfaces/AlterApolloServerPlugins.d.ts +0 -5
  58. package/lib/types/interfaces/AlterApolloSettings.d.ts +0 -7
  59. package/lib/types/interfaces/ApolloContext.d.ts +0 -4
  60. package/lib/types-esm/decorators/injectApolloContext.d.ts +0 -5
  61. package/lib/types-esm/interfaces/AlterApolloContext.d.ts +0 -5
  62. package/lib/types-esm/interfaces/AlterApolloServerPlugins.d.ts +0 -5
  63. package/lib/types-esm/interfaces/AlterApolloSettings.d.ts +0 -7
  64. package/lib/types-esm/interfaces/ApolloContext.d.ts +0 -4
package/readme.md CHANGED
@@ -45,7 +45,8 @@ If you're looking for integration with TypeGraphQL see the [`@tsed/typegraphql`]
45
45
  To begin, install the Apollo module for TS.ED:
46
46
 
47
47
  ```bash
48
- npm install --save @tsed/apollo graphql@15 @apollo/server apollo/datasource-rest
48
+ npm install --save @tsed/apollo graphql@15
49
+ npm install --save apollo-datasource apollo-datasource-rest apollo-server-express
49
50
  npm install --save-dev apollo-server-testing
50
51
  ```
51
52
 
@@ -67,6 +68,28 @@ import "@tsed/apollo";
67
68
  export class Server {}
68
69
  ```
69
70
 
71
+ ## ApolloService
72
+
73
+ ApolloService let you to retrieve an instance of ApolloServer.
74
+
75
+ ```typescript
76
+ import {Injectable, AfterRoutesInit} from "@tsed/common";
77
+ import {graphQLService} from "@tsed/apollo";
78
+ import {ApolloServer} from "apollo-server-express";
79
+
80
+ @Injectable()
81
+ export class UsersService implements AfterRoutesInit {
82
+ @Injec()
83
+ apolloService: ApolloService;
84
+
85
+ private server: ApolloServer;
86
+
87
+ $afterRoutesInit() {
88
+ this.server = this.apolloService.get("server1");
89
+ }
90
+ }
91
+ ```
92
+
70
93
  For more information about ApolloServer look his documentation [here](https://www.apollographql.com/docs/apollo-server/api/apollo-server.html);
71
94
 
72
95
  ## Contributors
package/vitest.config.mts CHANGED
@@ -10,12 +10,12 @@ export default defineConfig(
10
10
  coverage: {
11
11
  ...presets.test.coverage,
12
12
  thresholds: {
13
- statements: 81.52,
14
- branches: 81.81,
15
- functions: 94.73,
16
- lines: 81.52
13
+ statements: 0,
14
+ branches: 0,
15
+ functions: 0,
16
+ lines: 0
17
17
  }
18
18
  }
19
19
  }
20
20
  }
21
- );
21
+ );
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InjectApolloContext = void 0;
4
- const common_1 = require("@tsed/common");
5
- const core_1 = require("@tsed/core");
6
- const di_1 = require("@tsed/di");
7
- const constants_1 = require("../constants/constants");
8
- /**
9
- * Inject the Apollo context in the decorated property.
10
- * @decorator
11
- */
12
- function InjectApolloContext() {
13
- return (...args) => {
14
- switch ((0, core_1.decoratorTypeOf)(args)) {
15
- case core_1.DecoratorTypes.PARAM_CTOR:
16
- (0, di_1.Inject)(constants_1.APOLLO_CONTEXT)(...args);
17
- break;
18
- case core_1.DecoratorTypes.PROP:
19
- (0, common_1.injectProperty)(args[0], args[1], {
20
- resolver() {
21
- return () => (0, common_1.getContext)()?.get(constants_1.APOLLO_CONTEXT);
22
- }
23
- });
24
- }
25
- };
26
- }
27
- exports.InjectApolloContext = InjectApolloContext;
28
- //# sourceMappingURL=injectApolloContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectApolloContext.js","sourceRoot":"","sources":["../../../src/decorators/injectApolloContext.ts"],"names":[],"mappings":";;;AAAA,yCAAwD;AACxD,qCAAgF;AAChF,iCAAgC;AAChC,sDAAsD;AAEtD;;;GAGG;AACH,SAAgB,mBAAmB;IACjC,OAAO,CAAC,GAAG,IAAyB,EAAE,EAAE;QACtC,QAAQ,IAAA,sBAAe,EAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,qBAAc,CAAC,UAAU;gBAC5B,IAAA,WAAM,EAAC,0BAAc,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;gBAChC,MAAM;YAER,KAAK,qBAAc,CAAC,IAAI;gBACtB,IAAA,uBAAc,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAW,EAAE;oBACzC,QAAQ;wBACN,OAAO,GAAG,EAAE,CAAC,IAAA,mBAAU,GAAE,EAAE,GAAG,CAAC,0BAAc,CAAC,CAAC;oBACjD,CAAC;iBACF,CAAC,CAAC;SACN;IACH,CAAC,CAAC;AACJ,CAAC;AAfD,kDAeC"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=AlterApolloContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AlterApolloContext.js","sourceRoot":"","sources":["../../../src/interfaces/AlterApolloContext.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=AlterApolloServerPlugins.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AlterApolloServerPlugins.js","sourceRoot":"","sources":["../../../src/interfaces/AlterApolloServerPlugins.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=AlterApolloSettings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AlterApolloSettings.js","sourceRoot":"","sources":["../../../src/interfaces/AlterApolloSettings.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=ApolloContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ApolloContext.js","sourceRoot":"","sources":["../../../src/interfaces/ApolloContext.ts"],"names":[],"mappings":""}
@@ -1,24 +0,0 @@
1
- import { getContext, injectProperty } from "@tsed/common";
2
- import { decoratorTypeOf, DecoratorTypes } from "@tsed/core";
3
- import { Inject } from "@tsed/di";
4
- import { APOLLO_CONTEXT } from "../constants/constants.js";
5
- /**
6
- * Inject the Apollo context in the decorated property.
7
- * @decorator
8
- */
9
- export function InjectApolloContext() {
10
- return (...args) => {
11
- switch (decoratorTypeOf(args)) {
12
- case DecoratorTypes.PARAM_CTOR:
13
- Inject(APOLLO_CONTEXT)(...args);
14
- break;
15
- case DecoratorTypes.PROP:
16
- injectProperty(args[0], args[1], {
17
- resolver() {
18
- return () => getContext()?.get(APOLLO_CONTEXT);
19
- }
20
- });
21
- }
22
- };
23
- }
24
- //# sourceMappingURL=injectApolloContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectApolloContext.js","sourceRoot":"","sources":["../../../src/decorators/injectApolloContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC;AACxD,OAAO,EAAsB,eAAe,EAAE,cAAc,EAAC,MAAM,YAAY,CAAC;AAChF,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAEtD;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,CAAC,GAAG,IAAyB,EAAE,EAAE;QACtC,QAAQ,eAAe,CAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,cAAc,CAAC,UAAU;gBAC5B,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;gBAChC,MAAM;YAER,KAAK,cAAc,CAAC,IAAI;gBACtB,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAW,EAAE;oBACzC,QAAQ;wBACN,OAAO,GAAG,EAAE,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;oBACjD,CAAC;iBACF,CAAC,CAAC;SACN;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=AlterApolloContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AlterApolloContext.js","sourceRoot":"","sources":["../../../src/interfaces/AlterApolloContext.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=AlterApolloServerPlugins.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AlterApolloServerPlugins.js","sourceRoot":"","sources":["../../../src/interfaces/AlterApolloServerPlugins.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=AlterApolloSettings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AlterApolloSettings.js","sourceRoot":"","sources":["../../../src/interfaces/AlterApolloSettings.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=ApolloContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ApolloContext.js","sourceRoot":"","sources":["../../../src/interfaces/ApolloContext.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- /**
2
- * Inject the Apollo context in the decorated property.
3
- * @decorator
4
- */
5
- export declare function InjectApolloContext(): any;
@@ -1,5 +0,0 @@
1
- import type { PlatformContext } from "@tsed/common";
2
- import type { ApolloContext } from "./ApolloContext";
3
- export interface AlterApolloContext<Context extends ApolloContext = ApolloContext> {
4
- $alterApolloContext(context: Context, $ctx: PlatformContext): Context | Promise<Context>;
5
- }
@@ -1,5 +0,0 @@
1
- import type { ApolloServerPlugin } from "@apollo/server";
2
- import type { ApolloSettings } from "./ApolloSettings";
3
- export interface AlterApolloServerPlugins {
4
- $alterApolloServerPlugins(plugins: ApolloServerPlugin[], serverSettings: ApolloSettings): ApolloServerPlugin[] | Promise<ApolloServerPlugin[]>;
5
- }
@@ -1,7 +0,0 @@
1
- import type { ApolloContext } from "./ApolloContext.js";
2
- import type { ApolloSettingsWithID } from "./ApolloSettings.js";
3
- export interface AlterApolloSettings<Context extends ApolloContext = ApolloContext> {
4
- $alterApolloSettings(settings: ApolloSettingsWithID<Context>): (ApolloSettingsWithID<Context> & {
5
- id: string;
6
- }) | Promise<ApolloSettingsWithID<Context>>;
7
- }
@@ -1,4 +0,0 @@
1
- import type { BaseContext } from "@apollo/server";
2
- export interface ApolloContext extends BaseContext {
3
- dataSources: Record<string, unknown>;
4
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Inject the Apollo context in the decorated property.
3
- * @decorator
4
- */
5
- export declare function InjectApolloContext(): any;
@@ -1,5 +0,0 @@
1
- import type { PlatformContext } from "@tsed/common";
2
- import type { ApolloContext } from "./ApolloContext";
3
- export interface AlterApolloContext<Context extends ApolloContext = ApolloContext> {
4
- $alterApolloContext(context: Context, $ctx: PlatformContext): Context | Promise<Context>;
5
- }
@@ -1,5 +0,0 @@
1
- import type { ApolloServerPlugin } from "@apollo/server";
2
- import type { ApolloSettings } from "./ApolloSettings";
3
- export interface AlterApolloServerPlugins {
4
- $alterApolloServerPlugins(plugins: ApolloServerPlugin[], serverSettings: ApolloSettings): ApolloServerPlugin[] | Promise<ApolloServerPlugin[]>;
5
- }
@@ -1,7 +0,0 @@
1
- import type { ApolloContext } from "./ApolloContext.js";
2
- import type { ApolloSettingsWithID } from "./ApolloSettings.js";
3
- export interface AlterApolloSettings<Context extends ApolloContext = ApolloContext> {
4
- $alterApolloSettings(settings: ApolloSettingsWithID<Context>): (ApolloSettingsWithID<Context> & {
5
- id: string;
6
- }) | Promise<ApolloSettingsWithID<Context>>;
7
- }
@@ -1,4 +0,0 @@
1
- import type { BaseContext } from "@apollo/server";
2
- export interface ApolloContext extends BaseContext {
3
- dataSources: Record<string, unknown>;
4
- }