@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
@@ -1,15 +1,14 @@
1
- import { __decorate, __metadata } from "tslib";
2
- import { ApolloServer } from "@apollo/server";
3
- import { ApolloServerPluginLandingPageDisabled } from "@apollo/server/plugin/disabled";
4
- import { ApolloServerPluginDrainHttpServer } from "@apollo/server/plugin/drainHttpServer";
5
- import { ApolloServerPluginLandingPageLocalDefault } from "@apollo/server/plugin/landingPage/default";
6
- import { getContext, InjectorService, LocalsContainer, PlatformApplication } from "@tsed/common";
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { InjectorService, PlatformApplication } from "@tsed/common";
3
+ import { classOf, nameOf, Store } from "@tsed/core";
7
4
  import { Constant, Inject, Service } from "@tsed/di";
8
5
  import { Logger } from "@tsed/logger";
6
+ import { ApolloServerPluginDrainHttpServer, ApolloServerPluginLandingPageDisabled, ApolloServerPluginLandingPageLocalDefault } from "apollo-server-core";
9
7
  import Http from "http";
10
8
  import Https from "https";
11
- import { APOLLO_CONTEXT, DATASOURCES_PROVIDERS } from "../constants/constants.js";
9
+ import { DATASOURCES_PROVIDERS } from "../constants/constants.js";
12
10
  let ApolloService = class ApolloService {
11
+ dataSources;
13
12
  platformName;
14
13
  logger;
15
14
  /**
@@ -22,6 +21,9 @@ let ApolloService = class ApolloService {
22
21
  httpServer;
23
22
  httpsServer;
24
23
  injector;
24
+ constructor(dataSources) {
25
+ this.dataSources = dataSources;
26
+ }
25
27
  async createServer(id, settings) {
26
28
  if (!this.has(id)) {
27
29
  try {
@@ -29,40 +31,22 @@ let ApolloService = class ApolloService {
29
31
  this.logger.info(`Create server with Apollo for: ${id}`);
30
32
  this.logger.debug(`options: ${JSON.stringify({ path })}`);
31
33
  const plugins = await this.getPlugins(settings);
32
- const server = this.createInstance({
34
+ const server = await this.createInstance({
33
35
  ...config,
34
- plugins
36
+ plugins,
37
+ dataSources: this.createDataSources(dataSources)
35
38
  }, customServer);
36
39
  if (server) {
37
40
  this.servers.set(id || "default", {
38
41
  instance: server,
39
- schema: settings.schema,
40
- typeDefs: settings.typeDefs,
41
- resolvers: settings.resolvers
42
+ schema: settings.schema
42
43
  });
43
44
  await server.start();
44
- const contextHandler = this.createContextHandler(server, settings);
45
- switch (this.platformName) {
46
- case "express":
47
- const { expressMiddleware } = await import("@apollo/server/express4");
48
- this.app.use(path, expressMiddleware(server, {
49
- ...middlewareOptions,
50
- context: contextHandler
51
- }));
52
- break;
53
- case "koa":
54
- const { koaMiddleware } = await import("@as-integrations/koa");
55
- this.app.use(path, koaMiddleware(server, {
56
- ...middlewareOptions,
57
- context: contextHandler
58
- }));
59
- break;
60
- default:
61
- this.logger.warn({
62
- event: "APOLLO_UNKNOWN_PLATFORM",
63
- message: "Platform not supported. Please use Ts.ED platform (express, koa)"
64
- });
65
- }
45
+ const middleware = server.getMiddleware({
46
+ path: settings.path,
47
+ ...middlewareOptions
48
+ });
49
+ this.app.use(middleware);
66
50
  }
67
51
  }
68
52
  catch (er) {
@@ -72,7 +56,8 @@ let ApolloService = class ApolloService {
72
56
  message: er.message,
73
57
  stack: er.stack
74
58
  });
75
- throw er;
59
+ /* istanbul ignore next */
60
+ process.exit(-1);
76
61
  }
77
62
  }
78
63
  return this.get(id);
@@ -85,21 +70,12 @@ let ApolloService = class ApolloService {
85
70
  return this.servers.get(id)?.instance;
86
71
  }
87
72
  /**
88
- * Get schema of the ApolloServer from his id
73
+ * Get an instance of GraphQL schema from his id
89
74
  * @returns GraphQLSchema
90
75
  */
91
76
  getSchema(id = "default") {
92
77
  return this.servers.get(id)?.schema;
93
78
  }
94
- /**
95
- * Get TypeDefs of the ApolloServer from his id
96
- */
97
- getTypeDefs(id = "default") {
98
- return this.servers.get(id)?.typeDefs;
99
- }
100
- getResolvers(id = "default") {
101
- return this.servers.get(id)?.resolvers;
102
- }
103
79
  /**
104
80
  *
105
81
  * @param {string} id
@@ -108,42 +84,47 @@ let ApolloService = class ApolloService {
108
84
  has(id = "default") {
109
85
  return this.servers.has(id);
110
86
  }
87
+ async createInstance(options, server) {
88
+ if (server) {
89
+ return server(options);
90
+ }
91
+ const importServer = async () => {
92
+ switch (this.platformName) {
93
+ default:
94
+ this.logger.error(`Platform "${this.platformName}" not supported by @tsed/apollo`);
95
+ case "express":
96
+ return (await import("apollo-server-express")).ApolloServer;
97
+ case "koa":
98
+ return (await import("apollo-server-koa")).ApolloServer;
99
+ }
100
+ };
101
+ const Server = await importServer();
102
+ return new Server(options);
103
+ }
111
104
  /**
112
105
  * create a new dataSources function to use with apollo server config
106
+ * @param dataSources
113
107
  */
114
- createContextHandler(server, settings) {
115
- const { injector } = this;
116
- const dataSourcesContainer = injector.getProviders(DATASOURCES_PROVIDERS).reduce((map, provider) => {
117
- let { name } = provider.store.get(DATASOURCES_PROVIDERS);
118
- name = name || provider.className;
108
+ createDataSources(dataSources) {
109
+ const dataSourcesHash = this.dataSources.reduce((map, instance) => {
110
+ const klass = classOf(instance);
111
+ const store = Store.from(klass);
112
+ let { name } = store.get(DATASOURCES_PROVIDERS);
113
+ name = name || nameOf(klass);
119
114
  const sourceName = `${name[0].toLowerCase()}${name.slice(1)}`;
120
- map.set(sourceName, provider);
115
+ map[sourceName] = instance;
121
116
  return map;
122
- }, new Map());
123
- return async () => {
124
- const $ctx = getContext();
125
- const context = {
126
- dataSources: {
127
- ...(settings.dataSources?.() || {})
128
- }
117
+ }, {});
118
+ return () => {
119
+ return {
120
+ ...dataSourcesHash,
121
+ ...(dataSources ? dataSources() : {})
129
122
  };
130
- const alteredContext = await this.injector.alterAsync("$alterApolloContext", context, $ctx);
131
- $ctx.set(APOLLO_CONTEXT, alteredContext);
132
- const locals = new LocalsContainer();
133
- locals.set(APOLLO_CONTEXT, alteredContext);
134
- locals.set(ApolloServer, server);
135
- dataSourcesContainer.forEach((provider, key) => {
136
- alteredContext.dataSources[key] = injector.invoke(provider.token, locals);
137
- });
138
- return alteredContext;
139
123
  };
140
124
  }
141
- createInstance(options, server) {
142
- return server ? server(options) : new ApolloServer(options);
143
- }
144
125
  async getPlugins(serverSettings) {
145
126
  const playground = serverSettings.playground || (serverSettings.playground === undefined && process.env.NODE_ENV !== "production");
146
- const result = await this.injector.alterAsync("$alterApolloServerPlugins", [
127
+ const result = await this.injector.alter("$alterApolloServerPlugins", [
147
128
  this.httpServer &&
148
129
  ApolloServerPluginDrainHttpServer({
149
130
  httpServer: this.httpServer
@@ -184,7 +165,9 @@ __decorate([
184
165
  __metadata("design:type", InjectorService)
185
166
  ], ApolloService.prototype, "injector", void 0);
186
167
  ApolloService = __decorate([
187
- Service()
168
+ Service(),
169
+ __param(0, Inject(DATASOURCES_PROVIDERS)),
170
+ __metadata("design:paramtypes", [Array])
188
171
  ], ApolloService);
189
172
  export { ApolloService };
190
173
  //# sourceMappingURL=ApolloService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ApolloService.js","sourceRoot":"","sources":["../../../src/services/ApolloService.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,YAAY,EAA0C,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAC,qCAAqC,EAAC,MAAM,gCAAgC,CAAC;AACrF,OAAO,EAAC,iCAAiC,EAAC,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAC,yCAAyC,EAAC,MAAM,2CAA2C,CAAC;AAEpG,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAA4B,MAAM,cAAc,CAAC;AAC1H,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,UAAU,CAAC;AACnD,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAEpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,cAAc,EAAE,qBAAqB,EAAC,MAAM,2BAA2B,CAAC;AAKzE,IAAM,aAAa,GAAnB,MAAM,aAAa;IAExB,YAAY,CAAS;IAGX,MAAM,CAAS;IAEzB;;;;OAIG;IACO,OAAO,GAQb,IAAI,GAAG,EAAE,CAAC;IAGN,GAAG,CAA2B;IAG9B,UAAU,CAAqB;IAG/B,WAAW,CAAsB;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,CAAC,KAAK,CACtC,2BAA2B,EAC3B;YACE,IAAI,CAAC,UAAU;gBACb,iCAAiC,CAAC;oBAChC,UAAU,EAAE,IAAI,CAAC,UAAU;iBAC5B,CAAC;YACJ,IAAI,CAAC,WAAW;gBACd,iCAAiC,CAAC;oBAChC,UAAU,EAAE,IAAI,CAAC,WAAW;iBAC7B,CAAC;YACJ,GAAG,CAAC,cAAc,CAAC,OAAO,IAAI,EAAE,CAAC;SAClC,CAAC,MAAM,CAAC,OAAO,CAAC,EACjB,cAAc,CACf,CAAC;QAEF,OAAO,MAAM;aACV,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,yCAAyC,CAAC,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC,qCAAqC,EAAE,CAAC,CAAC;aACzH,MAAM,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;CACF,CAAA;AAjLC;IAAC,QAAQ,CAAC,eAAe,CAAC;;mDACL;AAErB;IAAC,MAAM,EAAE;8BACS,MAAM;6CAAC;AAezB;IAAC,MAAM,EAAE;8BACI,mBAAmB;0CAAM;AAEtC;IAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;;iDACmB;AAEvC;IAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;;kDACoB;AAEzC;IAAC,MAAM,EAAE;8BACS,eAAe;+CAAC;AA9BvB,aAAa;IADzB,OAAO,EAAE;IAiCK,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;;GAhC/B,aAAa,CAkLzB;SAlLY,aAAa"}
@@ -1,15 +1,14 @@
1
1
  import { AfterListen, Logger, OnRoutesInit } from "@tsed/common";
2
- import { Configuration, InjectorService } from "@tsed/di";
2
+ import { Configuration } from "@tsed/di";
3
3
  import { ApolloSettings } from "./interfaces/ApolloSettings.js";
4
4
  import { ApolloService } from "./services/ApolloService.js";
5
5
  export declare class ApolloModule implements OnRoutesInit, AfterListen {
6
6
  protected logger: Logger;
7
7
  protected service: ApolloService;
8
8
  protected configuration: Configuration;
9
- protected injector: InjectorService;
10
9
  get settings(): {
11
10
  [key: string]: ApolloSettings;
12
11
  } | undefined;
13
- $onRoutesInit(): Promise<void>;
12
+ $onRoutesInit(): Promise<any> | void;
14
13
  $afterListen(): Promise<any> | void;
15
14
  }
@@ -1,2 +1 @@
1
1
  export declare const DATASOURCES_PROVIDERS = "graphql:datasources";
2
- export declare const APOLLO_CONTEXT: unique symbol;
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * ```typescript
5
5
  * import { DataSourceService } from "@tsed/graphql";
6
- * import { RESTDataSource } from '@apollo/datasource-rest';
6
+ * import { RESTDataSource } from 'apollo-datasource-rest';
7
7
  *
8
8
  * @DataSource()
9
9
  * export class MyDataSource extends RESTDataSource {
@@ -31,7 +31,7 @@ export declare function DataSource(name?: string): ClassDecorator;
31
31
  *
32
32
  * ```typescript
33
33
  * import { DataSourceService } from "@tsed/graphql";
34
- * import { RESTDataSource } from '@apollo/datasource-rest';
34
+ * import { RESTDataSource } from 'apollo-datasource-rest';
35
35
  *
36
36
  * @DataSource()
37
37
  * export class MyDataSource extends RESTDataSource {
@@ -4,10 +4,5 @@
4
4
  export * from "./ApolloModule.js";
5
5
  export * from "./constants/constants.js";
6
6
  export * from "./decorators/dataSource.js";
7
- export * from "./decorators/injectApolloContext.js";
8
- export * from "./interfaces/AlterApolloContext.js";
9
- export * from "./interfaces/AlterApolloServerPlugins.js";
10
- export * from "./interfaces/AlterApolloSettings.js";
11
- export * from "./interfaces/ApolloContext.js";
12
7
  export * from "./interfaces/ApolloSettings.js";
13
8
  export * from "./services/ApolloService.js";
@@ -1,32 +1,20 @@
1
- import type { ApolloServer, ApolloServerOptions, ApolloServerOptionsWithSchema } from "@apollo/server";
2
- import type { GatewayInterface } from "@apollo/server-gateway-interface";
3
- import type { IExecutableSchemaDefinition } from "@graphql-tools/schema";
4
- import type { GraphQLSchema } from "graphql/index";
5
- import { ApolloContext } from "./ApolloContext";
1
+ import type { ApolloServerBase, ApolloServerPluginLandingPageGraphQLPlaygroundOptions, Config } from "apollo-server-core";
6
2
  export type ApolloMiddlewareOptions = Record<string, any>;
7
- export type ApolloCustomServerCB<TContext extends ApolloContext> = (config: ApolloServerOptions<TContext>) => ApolloServer<TContext>;
3
+ export type ApolloServer = ApolloServerBase & {
4
+ getMiddleware(settings: ApolloMiddlewareOptions): any;
5
+ };
6
+ export type ApolloCustomServerCB = (config: ApolloConfig) => ApolloServer;
7
+ export type ApolloConfig = Config;
8
8
  declare global {
9
9
  namespace TsED {
10
10
  interface ApolloSettings {
11
11
  }
12
12
  }
13
13
  }
14
- export type ApolloServerOptionsBase<TContext extends ApolloContext = ApolloContext> = Omit<ApolloServerOptionsWithSchema<TContext>, "schema" | "typeDefs" | "resolvers" | "gateway">;
15
- export type ApolloSettings<TContext extends ApolloContext = ApolloContext> = ApolloServerOptionsBase<TContext> & TsED.ApolloSettings & {
14
+ export interface ApolloSettings extends ApolloConfig, TsED.ApolloSettings {
16
15
  path: string;
17
- server?: ApolloCustomServerCB<TContext>;
18
- playground?: boolean;
16
+ server?: ApolloCustomServerCB;
17
+ playground?: boolean | ApolloServerPluginLandingPageGraphQLPlaygroundOptions;
19
18
  serverRegistration?: ApolloMiddlewareOptions;
20
19
  middlewareOptions?: ApolloMiddlewareOptions;
21
- schema?: GraphQLSchema;
22
- typeDefs?: IExecutableSchemaDefinition<TContext>["typeDefs"];
23
- resolvers?: IExecutableSchemaDefinition<TContext>["resolvers"];
24
- gateway?: GatewayInterface;
25
- /**
26
- * @deprecated use $alterApolloContext instead
27
- */
28
- dataSources?: () => Record<string, unknown>;
29
- };
30
- export type ApolloSettingsWithID<TContext extends ApolloContext = ApolloContext> = ApolloSettings<TContext> & {
31
- id: string;
32
- };
20
+ }
@@ -1,10 +1,11 @@
1
- import { ApolloServer, ApolloServerOptions } from "@apollo/server";
2
- import type { IExecutableSchemaDefinition } from "@graphql-tools/schema";
3
1
  import { Logger } from "@tsed/logger";
2
+ import type { Config } from "apollo-server-core";
3
+ import { ApolloServerBase } from "apollo-server-core";
4
4
  import type { GraphQLSchema } from "graphql";
5
- import { ApolloContext } from "../interfaces/ApolloContext.js";
6
- import type { ApolloCustomServerCB, ApolloSettings } from "../interfaces/ApolloSettings.js";
5
+ import type { ApolloServer, ApolloSettings } from "../interfaces/ApolloSettings.js";
6
+ import { ApolloCustomServerCB } from "../interfaces/ApolloSettings.js";
7
7
  export declare class ApolloService {
8
+ protected dataSources: any[];
8
9
  platformName: string;
9
10
  protected logger: Logger;
10
11
  /**
@@ -13,41 +14,36 @@ export declare class ApolloService {
13
14
  * @private
14
15
  */
15
16
  protected servers: Map<string, {
16
- instance: ApolloServer<ApolloContext>;
17
- schema?: GraphQLSchema;
18
- typeDefs?: IExecutableSchemaDefinition<ApolloContext>["typeDefs"];
19
- resolvers?: IExecutableSchemaDefinition<ApolloContext>["resolvers"];
17
+ instance: ApolloServerBase;
18
+ schema: GraphQLSchema | undefined;
20
19
  }>;
21
20
  private app;
22
21
  private httpServer;
23
22
  private httpsServer;
24
23
  private injector;
25
- createServer(id: string, settings: ApolloSettings): Promise<ApolloServer<ApolloContext>>;
24
+ constructor(dataSources: any[]);
25
+ createServer(id: string, settings: ApolloSettings): Promise<ApolloServer>;
26
26
  /**
27
27
  * Get an instance of ApolloServer from his id
28
28
  * @returns ApolloServer
29
29
  */
30
- get(id?: string): ApolloServer<ApolloContext> | undefined;
30
+ get(id?: string): ApolloServerBase | undefined;
31
31
  /**
32
- * Get schema of the ApolloServer from his id
32
+ * Get an instance of GraphQL schema from his id
33
33
  * @returns GraphQLSchema
34
34
  */
35
35
  getSchema(id?: string): GraphQLSchema | undefined;
36
- /**
37
- * Get TypeDefs of the ApolloServer from his id
38
- */
39
- getTypeDefs(id?: string): import("@graphql-tools/utils").TypeSource | undefined;
40
- getResolvers(id?: string): import("@graphql-tools/utils").IResolvers<any, ApolloContext, Record<string, any>, any> | import("@graphql-tools/utils").IResolvers<any, ApolloContext, Record<string, any>, any>[] | undefined;
41
36
  /**
42
37
  *
43
38
  * @param {string} id
44
39
  * @returns {boolean}
45
40
  */
46
41
  has(id?: string): boolean;
42
+ protected createInstance(options: Config, server?: ApolloCustomServerCB): Promise<ApolloServer | undefined>;
47
43
  /**
48
44
  * create a new dataSources function to use with apollo server config
45
+ * @param dataSources
49
46
  */
50
- createContextHandler(server: ApolloServer<ApolloContext>, settings: ApolloSettings): () => Promise<any>;
51
- protected createInstance(options: ApolloServerOptions<ApolloContext>, server?: ApolloCustomServerCB<ApolloContext>): ApolloServer<ApolloContext>;
47
+ protected createDataSources(dataSources: Function | undefined): () => any;
52
48
  private getPlugins;
53
49
  }
@@ -1,15 +1,14 @@
1
1
  import { AfterListen, Logger, OnRoutesInit } from "@tsed/common";
2
- import { Configuration, InjectorService } from "@tsed/di";
2
+ import { Configuration } from "@tsed/di";
3
3
  import { ApolloSettings } from "./interfaces/ApolloSettings.js";
4
4
  import { ApolloService } from "./services/ApolloService.js";
5
5
  export declare class ApolloModule implements OnRoutesInit, AfterListen {
6
6
  protected logger: Logger;
7
7
  protected service: ApolloService;
8
8
  protected configuration: Configuration;
9
- protected injector: InjectorService;
10
9
  get settings(): {
11
10
  [key: string]: ApolloSettings;
12
11
  } | undefined;
13
- $onRoutesInit(): Promise<void>;
12
+ $onRoutesInit(): Promise<any> | void;
14
13
  $afterListen(): Promise<any> | void;
15
14
  }
@@ -1,2 +1 @@
1
1
  export declare const DATASOURCES_PROVIDERS = "graphql:datasources";
2
- export declare const APOLLO_CONTEXT: unique symbol;
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * ```typescript
5
5
  * import { DataSourceService } from "@tsed/graphql";
6
- * import { RESTDataSource } from '@apollo/datasource-rest';
6
+ * import { RESTDataSource } from 'apollo-datasource-rest';
7
7
  *
8
8
  * @DataSource()
9
9
  * export class MyDataSource extends RESTDataSource {
@@ -31,7 +31,7 @@ export declare function DataSource(name?: string): ClassDecorator;
31
31
  *
32
32
  * ```typescript
33
33
  * import { DataSourceService } from "@tsed/graphql";
34
- * import { RESTDataSource } from '@apollo/datasource-rest';
34
+ * import { RESTDataSource } from 'apollo-datasource-rest';
35
35
  *
36
36
  * @DataSource()
37
37
  * export class MyDataSource extends RESTDataSource {
@@ -4,10 +4,5 @@
4
4
  export * from "./ApolloModule.js";
5
5
  export * from "./constants/constants.js";
6
6
  export * from "./decorators/dataSource.js";
7
- export * from "./decorators/injectApolloContext.js";
8
- export * from "./interfaces/AlterApolloContext.js";
9
- export * from "./interfaces/AlterApolloServerPlugins.js";
10
- export * from "./interfaces/AlterApolloSettings.js";
11
- export * from "./interfaces/ApolloContext.js";
12
7
  export * from "./interfaces/ApolloSettings.js";
13
8
  export * from "./services/ApolloService.js";
@@ -1,32 +1,20 @@
1
- import type { ApolloServer, ApolloServerOptions, ApolloServerOptionsWithSchema } from "@apollo/server";
2
- import type { GatewayInterface } from "@apollo/server-gateway-interface";
3
- import type { IExecutableSchemaDefinition } from "@graphql-tools/schema";
4
- import type { GraphQLSchema } from "graphql/index";
5
- import { ApolloContext } from "./ApolloContext";
1
+ import type { ApolloServerBase, ApolloServerPluginLandingPageGraphQLPlaygroundOptions, Config } from "apollo-server-core";
6
2
  export type ApolloMiddlewareOptions = Record<string, any>;
7
- export type ApolloCustomServerCB<TContext extends ApolloContext> = (config: ApolloServerOptions<TContext>) => ApolloServer<TContext>;
3
+ export type ApolloServer = ApolloServerBase & {
4
+ getMiddleware(settings: ApolloMiddlewareOptions): any;
5
+ };
6
+ export type ApolloCustomServerCB = (config: ApolloConfig) => ApolloServer;
7
+ export type ApolloConfig = Config;
8
8
  declare global {
9
9
  namespace TsED {
10
10
  interface ApolloSettings {
11
11
  }
12
12
  }
13
13
  }
14
- export type ApolloServerOptionsBase<TContext extends ApolloContext = ApolloContext> = Omit<ApolloServerOptionsWithSchema<TContext>, "schema" | "typeDefs" | "resolvers" | "gateway">;
15
- export type ApolloSettings<TContext extends ApolloContext = ApolloContext> = ApolloServerOptionsBase<TContext> & TsED.ApolloSettings & {
14
+ export interface ApolloSettings extends ApolloConfig, TsED.ApolloSettings {
16
15
  path: string;
17
- server?: ApolloCustomServerCB<TContext>;
18
- playground?: boolean;
16
+ server?: ApolloCustomServerCB;
17
+ playground?: boolean | ApolloServerPluginLandingPageGraphQLPlaygroundOptions;
19
18
  serverRegistration?: ApolloMiddlewareOptions;
20
19
  middlewareOptions?: ApolloMiddlewareOptions;
21
- schema?: GraphQLSchema;
22
- typeDefs?: IExecutableSchemaDefinition<TContext>["typeDefs"];
23
- resolvers?: IExecutableSchemaDefinition<TContext>["resolvers"];
24
- gateway?: GatewayInterface;
25
- /**
26
- * @deprecated use $alterApolloContext instead
27
- */
28
- dataSources?: () => Record<string, unknown>;
29
- };
30
- export type ApolloSettingsWithID<TContext extends ApolloContext = ApolloContext> = ApolloSettings<TContext> & {
31
- id: string;
32
- };
20
+ }
@@ -1,10 +1,11 @@
1
- import { ApolloServer, ApolloServerOptions } from "@apollo/server";
2
- import type { IExecutableSchemaDefinition } from "@graphql-tools/schema";
3
1
  import { Logger } from "@tsed/logger";
2
+ import type { Config } from "apollo-server-core";
3
+ import { ApolloServerBase } from "apollo-server-core";
4
4
  import type { GraphQLSchema } from "graphql";
5
- import { ApolloContext } from "../interfaces/ApolloContext.js";
6
- import type { ApolloCustomServerCB, ApolloSettings } from "../interfaces/ApolloSettings.js";
5
+ import type { ApolloServer, ApolloSettings } from "../interfaces/ApolloSettings.js";
6
+ import { ApolloCustomServerCB } from "../interfaces/ApolloSettings.js";
7
7
  export declare class ApolloService {
8
+ protected dataSources: any[];
8
9
  platformName: string;
9
10
  protected logger: Logger;
10
11
  /**
@@ -13,41 +14,36 @@ export declare class ApolloService {
13
14
  * @private
14
15
  */
15
16
  protected servers: Map<string, {
16
- instance: ApolloServer<ApolloContext>;
17
- schema?: GraphQLSchema;
18
- typeDefs?: IExecutableSchemaDefinition<ApolloContext>["typeDefs"];
19
- resolvers?: IExecutableSchemaDefinition<ApolloContext>["resolvers"];
17
+ instance: ApolloServerBase;
18
+ schema: GraphQLSchema | undefined;
20
19
  }>;
21
20
  private app;
22
21
  private httpServer;
23
22
  private httpsServer;
24
23
  private injector;
25
- createServer(id: string, settings: ApolloSettings): Promise<ApolloServer<ApolloContext>>;
24
+ constructor(dataSources: any[]);
25
+ createServer(id: string, settings: ApolloSettings): Promise<ApolloServer>;
26
26
  /**
27
27
  * Get an instance of ApolloServer from his id
28
28
  * @returns ApolloServer
29
29
  */
30
- get(id?: string): ApolloServer<ApolloContext> | undefined;
30
+ get(id?: string): ApolloServerBase | undefined;
31
31
  /**
32
- * Get schema of the ApolloServer from his id
32
+ * Get an instance of GraphQL schema from his id
33
33
  * @returns GraphQLSchema
34
34
  */
35
35
  getSchema(id?: string): GraphQLSchema | undefined;
36
- /**
37
- * Get TypeDefs of the ApolloServer from his id
38
- */
39
- getTypeDefs(id?: string): import("@graphql-tools/utils").TypeSource | undefined;
40
- getResolvers(id?: string): import("@graphql-tools/utils").IResolvers<any, ApolloContext, Record<string, any>, any> | import("@graphql-tools/utils").IResolvers<any, ApolloContext, Record<string, any>, any>[] | undefined;
41
36
  /**
42
37
  *
43
38
  * @param {string} id
44
39
  * @returns {boolean}
45
40
  */
46
41
  has(id?: string): boolean;
42
+ protected createInstance(options: Config, server?: ApolloCustomServerCB): Promise<ApolloServer | undefined>;
47
43
  /**
48
44
  * create a new dataSources function to use with apollo server config
45
+ * @param dataSources
49
46
  */
50
- createContextHandler(server: ApolloServer<ApolloContext>, settings: ApolloSettings): () => Promise<any>;
51
- protected createInstance(options: ApolloServerOptions<ApolloContext>, server?: ApolloCustomServerCB<ApolloContext>): ApolloServer<ApolloContext>;
47
+ protected createDataSources(dataSources: Function | undefined): () => any;
52
48
  private getPlugins;
53
49
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tsed/apollo",
3
3
  "description": "Apollo package for Ts.ED framework",
4
4
  "type": "commonjs",
5
- "version": "7.81.0-rc.1",
5
+ "version": "7.81.0",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/cjs/index.js",
8
8
  "module": "./lib/esm/index.js",
@@ -26,31 +26,33 @@
26
26
  "tslib": "2.6.1"
27
27
  },
28
28
  "devDependencies": {
29
- "@apollo/datasource-rest": "6.2.2",
30
- "@apollo/server": "^4.10.4",
31
- "@as-integrations/koa": "1.1.1",
32
- "@tsed/barrels": "7.81.0-rc.1",
33
- "@tsed/common": "7.81.0-rc.1",
34
- "@tsed/core": "7.81.0-rc.1",
35
- "@tsed/di": "7.81.0-rc.1",
29
+ "@tsed/barrels": "7.81.0",
30
+ "@tsed/common": "7.81.0",
31
+ "@tsed/core": "7.81.0",
32
+ "@tsed/di": "7.81.0",
36
33
  "@tsed/logger": ">=6.7.5",
37
- "@tsed/typescript": "7.81.0-rc.1",
38
- "apollo-datasource-http": "0.21.0",
39
- "apollo-server-testing": "2.25.3",
34
+ "@tsed/typescript": "7.81.0",
35
+ "@types/graphql": "14.5.0",
36
+ "apollo-datasource": "^3.3.2",
37
+ "apollo-datasource-rest": "^3.7.0",
38
+ "apollo-server-core": "^3.13.0",
39
+ "apollo-server-express": "^3.13.0",
40
+ "apollo-server-koa": "^3.13.0",
41
+ "apollo-server-testing": "^2.26.2",
40
42
  "eslint": "^8.57.0",
41
- "graphql": "16.8.2",
43
+ "graphql": "15.8.0",
42
44
  "typescript": "4.9.5",
43
45
  "vitest": "2.0.4"
44
46
  },
45
47
  "peerDependencies": {
46
- "@apollo/datasource-http": "",
47
- "@apollo/datasource-rest": ">=6.2.2",
48
- "@apollo/server": ">=4.10.4",
49
- "@tsed/common": "7.81.0-rc.1",
50
- "@tsed/core": "7.81.0-rc.1",
51
- "@tsed/di": "7.81.0-rc.1",
48
+ "@tsed/common": "7.81.0",
49
+ "@tsed/core": "7.81.0",
50
+ "@tsed/di": "7.81.0",
52
51
  "@tsed/logger": ">=6.7.5",
53
- "graphql": ">16.0.0"
52
+ "apollo-datasource": ">=3.0.0",
53
+ "apollo-datasource-rest": ">=3.0.0",
54
+ "apollo-server-core": ">=3.0.0",
55
+ "graphql": ">15.0.0"
54
56
  },
55
57
  "repository": "https://github.com/tsedio/tsed",
56
58
  "bugs": {
@@ -58,8 +60,5 @@
58
60
  },
59
61
  "homepage": "https://github.com/tsedio/tsed/tree/production/packages/graphql/apollo",
60
62
  "author": "Romain Lenzotti",
61
- "license": "MIT",
62
- "publishConfig": {
63
- "tag": "rc"
64
- }
63
+ "license": "MIT"
65
64
  }