@tsed/apollo 7.80.3 → 7.81.0-rc.2
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/ApolloModule.js +13 -7
- package/lib/cjs/ApolloModule.js.map +1 -1
- package/lib/cjs/constants/constants.js +2 -1
- package/lib/cjs/constants/constants.js.map +1 -1
- package/lib/cjs/decorators/dataSource.js +2 -2
- package/lib/cjs/decorators/injectApolloContext.js +28 -0
- package/lib/cjs/decorators/injectApolloContext.js.map +1 -0
- package/lib/cjs/index.js +5 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces/AlterApolloContext.js +3 -0
- package/lib/cjs/interfaces/AlterApolloContext.js.map +1 -0
- package/lib/cjs/interfaces/AlterApolloServerPlugins.js +3 -0
- package/lib/cjs/interfaces/AlterApolloServerPlugins.js.map +1 -0
- package/lib/cjs/interfaces/AlterApolloSettings.js +3 -0
- package/lib/cjs/interfaces/AlterApolloSettings.js.map +1 -0
- package/lib/cjs/interfaces/ApolloContext.js +3 -0
- package/lib/cjs/interfaces/ApolloContext.js.map +1 -0
- package/lib/cjs/services/ApolloService.js +72 -55
- package/lib/cjs/services/ApolloService.js.map +1 -1
- package/lib/esm/ApolloModule.js +14 -8
- package/lib/esm/ApolloModule.js.map +1 -1
- package/lib/esm/constants/constants.js +1 -0
- package/lib/esm/constants/constants.js.map +1 -1
- package/lib/esm/decorators/dataSource.js +2 -2
- package/lib/esm/decorators/injectApolloContext.js +24 -0
- package/lib/esm/decorators/injectApolloContext.js.map +1 -0
- package/lib/esm/index.js +5 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/AlterApolloContext.js +2 -0
- package/lib/esm/interfaces/AlterApolloContext.js.map +1 -0
- package/lib/esm/interfaces/AlterApolloServerPlugins.js +2 -0
- package/lib/esm/interfaces/AlterApolloServerPlugins.js.map +1 -0
- package/lib/esm/interfaces/AlterApolloSettings.js +2 -0
- package/lib/esm/interfaces/AlterApolloSettings.js.map +1 -0
- package/lib/esm/interfaces/ApolloContext.js +2 -0
- package/lib/esm/interfaces/ApolloContext.js.map +1 -0
- package/lib/esm/services/ApolloService.js +72 -55
- package/lib/esm/services/ApolloService.js.map +1 -1
- package/lib/types/ApolloModule.d.ts +3 -2
- package/lib/types/constants/constants.d.ts +1 -0
- package/lib/types/decorators/dataSource.d.ts +2 -2
- package/lib/types/decorators/injectApolloContext.d.ts +5 -0
- package/lib/types/index.d.ts +5 -0
- package/lib/types/interfaces/AlterApolloContext.d.ts +5 -0
- package/lib/types/interfaces/AlterApolloServerPlugins.d.ts +5 -0
- package/lib/types/interfaces/AlterApolloSettings.d.ts +7 -0
- package/lib/types/interfaces/ApolloContext.d.ts +4 -0
- package/lib/types/interfaces/ApolloSettings.d.ts +22 -10
- package/lib/types/services/ApolloService.d.ts +18 -14
- package/lib/types-esm/ApolloModule.d.ts +3 -2
- package/lib/types-esm/constants/constants.d.ts +1 -0
- package/lib/types-esm/decorators/dataSource.d.ts +2 -2
- package/lib/types-esm/decorators/injectApolloContext.d.ts +5 -0
- package/lib/types-esm/index.d.ts +5 -0
- package/lib/types-esm/interfaces/AlterApolloContext.d.ts +5 -0
- package/lib/types-esm/interfaces/AlterApolloServerPlugins.d.ts +5 -0
- package/lib/types-esm/interfaces/AlterApolloSettings.d.ts +7 -0
- package/lib/types-esm/interfaces/ApolloContext.d.ts +4 -0
- package/lib/types-esm/interfaces/ApolloSettings.d.ts +22 -10
- package/lib/types-esm/services/ApolloService.d.ts +18 -14
- package/package.json +21 -22
- package/readme.md +1 -24
- package/vitest.config.mts +5 -5
- package/.nycrc +0 -26
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { __decorate, __metadata
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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";
|
|
4
7
|
import { Constant, Inject, Service } from "@tsed/di";
|
|
5
8
|
import { Logger } from "@tsed/logger";
|
|
6
|
-
import { ApolloServerPluginDrainHttpServer, ApolloServerPluginLandingPageDisabled, ApolloServerPluginLandingPageLocalDefault } from "apollo-server-core";
|
|
7
9
|
import Http from "http";
|
|
8
10
|
import Https from "https";
|
|
9
|
-
import { DATASOURCES_PROVIDERS } from "../constants/constants.js";
|
|
11
|
+
import { APOLLO_CONTEXT, DATASOURCES_PROVIDERS } from "../constants/constants.js";
|
|
10
12
|
let ApolloService = class ApolloService {
|
|
11
|
-
dataSources;
|
|
12
13
|
platformName;
|
|
13
14
|
logger;
|
|
14
15
|
/**
|
|
@@ -21,9 +22,6 @@ let ApolloService = class ApolloService {
|
|
|
21
22
|
httpServer;
|
|
22
23
|
httpsServer;
|
|
23
24
|
injector;
|
|
24
|
-
constructor(dataSources) {
|
|
25
|
-
this.dataSources = dataSources;
|
|
26
|
-
}
|
|
27
25
|
async createServer(id, settings) {
|
|
28
26
|
if (!this.has(id)) {
|
|
29
27
|
try {
|
|
@@ -31,22 +29,40 @@ let ApolloService = class ApolloService {
|
|
|
31
29
|
this.logger.info(`Create server with Apollo for: ${id}`);
|
|
32
30
|
this.logger.debug(`options: ${JSON.stringify({ path })}`);
|
|
33
31
|
const plugins = await this.getPlugins(settings);
|
|
34
|
-
const server =
|
|
32
|
+
const server = this.createInstance({
|
|
35
33
|
...config,
|
|
36
|
-
plugins
|
|
37
|
-
dataSources: this.createDataSources(dataSources)
|
|
34
|
+
plugins
|
|
38
35
|
}, customServer);
|
|
39
36
|
if (server) {
|
|
40
37
|
this.servers.set(id || "default", {
|
|
41
38
|
instance: server,
|
|
42
|
-
schema: settings.schema
|
|
39
|
+
schema: settings.schema,
|
|
40
|
+
typeDefs: settings.typeDefs,
|
|
41
|
+
resolvers: settings.resolvers
|
|
43
42
|
});
|
|
44
43
|
await server.start();
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
+
}
|
|
50
66
|
}
|
|
51
67
|
}
|
|
52
68
|
catch (er) {
|
|
@@ -56,8 +72,7 @@ let ApolloService = class ApolloService {
|
|
|
56
72
|
message: er.message,
|
|
57
73
|
stack: er.stack
|
|
58
74
|
});
|
|
59
|
-
|
|
60
|
-
process.exit(-1);
|
|
75
|
+
throw er;
|
|
61
76
|
}
|
|
62
77
|
}
|
|
63
78
|
return this.get(id);
|
|
@@ -70,12 +85,21 @@ let ApolloService = class ApolloService {
|
|
|
70
85
|
return this.servers.get(id)?.instance;
|
|
71
86
|
}
|
|
72
87
|
/**
|
|
73
|
-
* Get
|
|
88
|
+
* Get schema of the ApolloServer from his id
|
|
74
89
|
* @returns GraphQLSchema
|
|
75
90
|
*/
|
|
76
91
|
getSchema(id = "default") {
|
|
77
92
|
return this.servers.get(id)?.schema;
|
|
78
93
|
}
|
|
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
|
+
}
|
|
79
103
|
/**
|
|
80
104
|
*
|
|
81
105
|
* @param {string} id
|
|
@@ -84,47 +108,42 @@ let ApolloService = class ApolloService {
|
|
|
84
108
|
has(id = "default") {
|
|
85
109
|
return this.servers.has(id);
|
|
86
110
|
}
|
|
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
|
-
}
|
|
104
111
|
/**
|
|
105
112
|
* create a new dataSources function to use with apollo server config
|
|
106
|
-
* @param dataSources
|
|
107
113
|
*/
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
name = name || nameOf(klass);
|
|
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;
|
|
114
119
|
const sourceName = `${name[0].toLowerCase()}${name.slice(1)}`;
|
|
115
|
-
map
|
|
120
|
+
map.set(sourceName, provider);
|
|
116
121
|
return map;
|
|
117
|
-
},
|
|
118
|
-
return () => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
}, new Map());
|
|
123
|
+
return async () => {
|
|
124
|
+
const $ctx = getContext();
|
|
125
|
+
const context = {
|
|
126
|
+
dataSources: {
|
|
127
|
+
...(settings.dataSources?.() || {})
|
|
128
|
+
}
|
|
122
129
|
};
|
|
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;
|
|
123
139
|
};
|
|
124
140
|
}
|
|
141
|
+
createInstance(options, server) {
|
|
142
|
+
return server ? server(options) : new ApolloServer(options);
|
|
143
|
+
}
|
|
125
144
|
async getPlugins(serverSettings) {
|
|
126
145
|
const playground = serverSettings.playground || (serverSettings.playground === undefined && process.env.NODE_ENV !== "production");
|
|
127
|
-
const result = await this.injector.
|
|
146
|
+
const result = await this.injector.alterAsync("$alterApolloServerPlugins", [
|
|
128
147
|
this.httpServer &&
|
|
129
148
|
ApolloServerPluginDrainHttpServer({
|
|
130
149
|
httpServer: this.httpServer
|
|
@@ -165,9 +184,7 @@ __decorate([
|
|
|
165
184
|
__metadata("design:type", InjectorService)
|
|
166
185
|
], ApolloService.prototype, "injector", void 0);
|
|
167
186
|
ApolloService = __decorate([
|
|
168
|
-
Service()
|
|
169
|
-
__param(0, Inject(DATASOURCES_PROVIDERS)),
|
|
170
|
-
__metadata("design:paramtypes", [Array])
|
|
187
|
+
Service()
|
|
171
188
|
], ApolloService);
|
|
172
189
|
export { ApolloService };
|
|
173
190
|
//# sourceMappingURL=ApolloService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApolloService.js","sourceRoot":"","sources":["../../../src/services/ApolloService.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,
|
|
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;IAGjC,QAAQ,CAAkB;IAElC,KAAK,CAAC,YAAY,CAAC,EAAU,EAAE,QAAwB;QACrD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YACjB,IAAI;gBACF,MAAM,EAAC,WAAW,EAAE,IAAI,EA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AAlNC;IAAC,QAAQ,CAAC,eAAe,CAAC;;mDACL;AAErB;IAAC,MAAM,EAAE;8BACS,MAAM;6CAAC;AAiBzB;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;AAhCvB,aAAa;IADzB,OAAO,EAAE;GACG,aAAa,CAmNzB;SAnNY,aAAa"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { AfterListen, Logger, OnRoutesInit } from "@tsed/common";
|
|
2
|
-
import { Configuration } from "@tsed/di";
|
|
2
|
+
import { Configuration, InjectorService } 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;
|
|
9
10
|
get settings(): {
|
|
10
11
|
[key: string]: ApolloSettings;
|
|
11
12
|
} | undefined;
|
|
12
|
-
$onRoutesInit(): Promise<
|
|
13
|
+
$onRoutesInit(): Promise<void>;
|
|
13
14
|
$afterListen(): Promise<any> | void;
|
|
14
15
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* ```typescript
|
|
5
5
|
* import { DataSourceService } from "@tsed/graphql";
|
|
6
|
-
* import { RESTDataSource } from 'apollo
|
|
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
|
|
34
|
+
* import { RESTDataSource } from '@apollo/datasource-rest';
|
|
35
35
|
*
|
|
36
36
|
* @DataSource()
|
|
37
37
|
* export class MyDataSource extends RESTDataSource {
|
package/lib/types/index.d.ts
CHANGED
|
@@ -4,5 +4,10 @@
|
|
|
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";
|
|
7
12
|
export * from "./interfaces/ApolloSettings.js";
|
|
8
13
|
export * from "./services/ApolloService.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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,20 +1,32 @@
|
|
|
1
|
-
import type {
|
|
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";
|
|
2
6
|
export type ApolloMiddlewareOptions = Record<string, any>;
|
|
3
|
-
export type
|
|
4
|
-
getMiddleware(settings: ApolloMiddlewareOptions): any;
|
|
5
|
-
};
|
|
6
|
-
export type ApolloCustomServerCB = (config: ApolloConfig) => ApolloServer;
|
|
7
|
-
export type ApolloConfig = Config;
|
|
7
|
+
export type ApolloCustomServerCB<TContext extends ApolloContext> = (config: ApolloServerOptions<TContext>) => ApolloServer<TContext>;
|
|
8
8
|
declare global {
|
|
9
9
|
namespace TsED {
|
|
10
10
|
interface ApolloSettings {
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
export
|
|
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 & {
|
|
15
16
|
path: string;
|
|
16
|
-
server?: ApolloCustomServerCB
|
|
17
|
-
playground?: boolean
|
|
17
|
+
server?: ApolloCustomServerCB<TContext>;
|
|
18
|
+
playground?: boolean;
|
|
18
19
|
serverRegistration?: ApolloMiddlewareOptions;
|
|
19
20
|
middlewareOptions?: ApolloMiddlewareOptions;
|
|
20
|
-
|
|
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
|
+
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { ApolloServer, ApolloServerOptions } from "@apollo/server";
|
|
2
|
+
import type { IExecutableSchemaDefinition } from "@graphql-tools/schema";
|
|
1
3
|
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
|
|
6
|
-
import { ApolloCustomServerCB } from "../interfaces/ApolloSettings.js";
|
|
5
|
+
import { ApolloContext } from "../interfaces/ApolloContext.js";
|
|
6
|
+
import type { ApolloCustomServerCB, ApolloSettings } from "../interfaces/ApolloSettings.js";
|
|
7
7
|
export declare class ApolloService {
|
|
8
|
-
protected dataSources: any[];
|
|
9
8
|
platformName: string;
|
|
10
9
|
protected logger: Logger;
|
|
11
10
|
/**
|
|
@@ -14,36 +13,41 @@ export declare class ApolloService {
|
|
|
14
13
|
* @private
|
|
15
14
|
*/
|
|
16
15
|
protected servers: Map<string, {
|
|
17
|
-
instance:
|
|
18
|
-
schema
|
|
16
|
+
instance: ApolloServer<ApolloContext>;
|
|
17
|
+
schema?: GraphQLSchema;
|
|
18
|
+
typeDefs?: IExecutableSchemaDefinition<ApolloContext>["typeDefs"];
|
|
19
|
+
resolvers?: IExecutableSchemaDefinition<ApolloContext>["resolvers"];
|
|
19
20
|
}>;
|
|
20
21
|
private app;
|
|
21
22
|
private httpServer;
|
|
22
23
|
private httpsServer;
|
|
23
24
|
private injector;
|
|
24
|
-
|
|
25
|
-
createServer(id: string, settings: ApolloSettings): Promise<ApolloServer>;
|
|
25
|
+
createServer(id: string, settings: ApolloSettings): Promise<ApolloServer<ApolloContext>>;
|
|
26
26
|
/**
|
|
27
27
|
* Get an instance of ApolloServer from his id
|
|
28
28
|
* @returns ApolloServer
|
|
29
29
|
*/
|
|
30
|
-
get(id?: string):
|
|
30
|
+
get(id?: string): ApolloServer<ApolloContext> | undefined;
|
|
31
31
|
/**
|
|
32
|
-
* Get
|
|
32
|
+
* Get schema of the ApolloServer 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;
|
|
36
41
|
/**
|
|
37
42
|
*
|
|
38
43
|
* @param {string} id
|
|
39
44
|
* @returns {boolean}
|
|
40
45
|
*/
|
|
41
46
|
has(id?: string): boolean;
|
|
42
|
-
protected createInstance(options: Config, server?: ApolloCustomServerCB): Promise<ApolloServer | undefined>;
|
|
43
47
|
/**
|
|
44
48
|
* create a new dataSources function to use with apollo server config
|
|
45
|
-
* @param dataSources
|
|
46
49
|
*/
|
|
47
|
-
|
|
50
|
+
createContextHandler(server: ApolloServer<ApolloContext>, settings: ApolloSettings): () => Promise<any>;
|
|
51
|
+
protected createInstance(options: ApolloServerOptions<ApolloContext>, server?: ApolloCustomServerCB<ApolloContext>): ApolloServer<ApolloContext>;
|
|
48
52
|
private getPlugins;
|
|
49
53
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { AfterListen, Logger, OnRoutesInit } from "@tsed/common";
|
|
2
|
-
import { Configuration } from "@tsed/di";
|
|
2
|
+
import { Configuration, InjectorService } 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;
|
|
9
10
|
get settings(): {
|
|
10
11
|
[key: string]: ApolloSettings;
|
|
11
12
|
} | undefined;
|
|
12
|
-
$onRoutesInit(): Promise<
|
|
13
|
+
$onRoutesInit(): Promise<void>;
|
|
13
14
|
$afterListen(): Promise<any> | void;
|
|
14
15
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* ```typescript
|
|
5
5
|
* import { DataSourceService } from "@tsed/graphql";
|
|
6
|
-
* import { RESTDataSource } from 'apollo
|
|
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
|
|
34
|
+
* import { RESTDataSource } from '@apollo/datasource-rest';
|
|
35
35
|
*
|
|
36
36
|
* @DataSource()
|
|
37
37
|
* export class MyDataSource extends RESTDataSource {
|
package/lib/types-esm/index.d.ts
CHANGED
|
@@ -4,5 +4,10 @@
|
|
|
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";
|
|
7
12
|
export * from "./interfaces/ApolloSettings.js";
|
|
8
13
|
export * from "./services/ApolloService.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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,20 +1,32 @@
|
|
|
1
|
-
import type {
|
|
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";
|
|
2
6
|
export type ApolloMiddlewareOptions = Record<string, any>;
|
|
3
|
-
export type
|
|
4
|
-
getMiddleware(settings: ApolloMiddlewareOptions): any;
|
|
5
|
-
};
|
|
6
|
-
export type ApolloCustomServerCB = (config: ApolloConfig) => ApolloServer;
|
|
7
|
-
export type ApolloConfig = Config;
|
|
7
|
+
export type ApolloCustomServerCB<TContext extends ApolloContext> = (config: ApolloServerOptions<TContext>) => ApolloServer<TContext>;
|
|
8
8
|
declare global {
|
|
9
9
|
namespace TsED {
|
|
10
10
|
interface ApolloSettings {
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
export
|
|
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 & {
|
|
15
16
|
path: string;
|
|
16
|
-
server?: ApolloCustomServerCB
|
|
17
|
-
playground?: boolean
|
|
17
|
+
server?: ApolloCustomServerCB<TContext>;
|
|
18
|
+
playground?: boolean;
|
|
18
19
|
serverRegistration?: ApolloMiddlewareOptions;
|
|
19
20
|
middlewareOptions?: ApolloMiddlewareOptions;
|
|
20
|
-
|
|
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
|
+
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { ApolloServer, ApolloServerOptions } from "@apollo/server";
|
|
2
|
+
import type { IExecutableSchemaDefinition } from "@graphql-tools/schema";
|
|
1
3
|
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
|
|
6
|
-
import { ApolloCustomServerCB } from "../interfaces/ApolloSettings.js";
|
|
5
|
+
import { ApolloContext } from "../interfaces/ApolloContext.js";
|
|
6
|
+
import type { ApolloCustomServerCB, ApolloSettings } from "../interfaces/ApolloSettings.js";
|
|
7
7
|
export declare class ApolloService {
|
|
8
|
-
protected dataSources: any[];
|
|
9
8
|
platformName: string;
|
|
10
9
|
protected logger: Logger;
|
|
11
10
|
/**
|
|
@@ -14,36 +13,41 @@ export declare class ApolloService {
|
|
|
14
13
|
* @private
|
|
15
14
|
*/
|
|
16
15
|
protected servers: Map<string, {
|
|
17
|
-
instance:
|
|
18
|
-
schema
|
|
16
|
+
instance: ApolloServer<ApolloContext>;
|
|
17
|
+
schema?: GraphQLSchema;
|
|
18
|
+
typeDefs?: IExecutableSchemaDefinition<ApolloContext>["typeDefs"];
|
|
19
|
+
resolvers?: IExecutableSchemaDefinition<ApolloContext>["resolvers"];
|
|
19
20
|
}>;
|
|
20
21
|
private app;
|
|
21
22
|
private httpServer;
|
|
22
23
|
private httpsServer;
|
|
23
24
|
private injector;
|
|
24
|
-
|
|
25
|
-
createServer(id: string, settings: ApolloSettings): Promise<ApolloServer>;
|
|
25
|
+
createServer(id: string, settings: ApolloSettings): Promise<ApolloServer<ApolloContext>>;
|
|
26
26
|
/**
|
|
27
27
|
* Get an instance of ApolloServer from his id
|
|
28
28
|
* @returns ApolloServer
|
|
29
29
|
*/
|
|
30
|
-
get(id?: string):
|
|
30
|
+
get(id?: string): ApolloServer<ApolloContext> | undefined;
|
|
31
31
|
/**
|
|
32
|
-
* Get
|
|
32
|
+
* Get schema of the ApolloServer 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;
|
|
36
41
|
/**
|
|
37
42
|
*
|
|
38
43
|
* @param {string} id
|
|
39
44
|
* @returns {boolean}
|
|
40
45
|
*/
|
|
41
46
|
has(id?: string): boolean;
|
|
42
|
-
protected createInstance(options: Config, server?: ApolloCustomServerCB): Promise<ApolloServer | undefined>;
|
|
43
47
|
/**
|
|
44
48
|
* create a new dataSources function to use with apollo server config
|
|
45
|
-
* @param dataSources
|
|
46
49
|
*/
|
|
47
|
-
|
|
50
|
+
createContextHandler(server: ApolloServer<ApolloContext>, settings: ApolloSettings): () => Promise<any>;
|
|
51
|
+
protected createInstance(options: ApolloServerOptions<ApolloContext>, server?: ApolloCustomServerCB<ApolloContext>): ApolloServer<ApolloContext>;
|
|
48
52
|
private getPlugins;
|
|
49
53
|
}
|