@tsed/typegraphql 8.0.0-alpha.1 → 8.0.0-alpha.11
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/esm/TypeGraphQLModule.js +37 -29
- package/lib/esm/TypeGraphQLModule.js.map +1 -1
- package/lib/esm/decorators/resolver.js +0 -6
- package/lib/esm/decorators/resolver.js.map +1 -1
- package/lib/esm/index.js +0 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/interfaces.js +1 -1
- package/lib/esm/interfaces/interfaces.js.map +1 -1
- package/lib/esm/middlewares/ContextMiddleware.js +4 -3
- package/lib/esm/middlewares/ContextMiddleware.js.map +1 -1
- package/lib/types/TypeGraphQLModule.d.ts +6 -9
- package/lib/types/decorators/resolver.d.ts +4 -12
- package/lib/types/index.d.ts +0 -1
- package/lib/types/interfaces/TypeGraphQLSettings.d.ts +1 -6
- package/lib/types/interfaces/interfaces.d.ts +13 -4
- package/lib/types/middlewares/ContextMiddleware.d.ts +2 -2
- package/package.json +24 -20
- package/readme.md +31 -31
- package/vitest.config.mts +3 -3
- package/.nycrc +0 -27
- package/lib/cjs/TypeGraphQLModule.js +0 -54
- package/lib/cjs/TypeGraphQLModule.js.map +0 -1
- package/lib/cjs/constants/constants.js +0 -5
- package/lib/cjs/constants/constants.js.map +0 -1
- package/lib/cjs/decorators/resolver.js +0 -39
- package/lib/cjs/decorators/resolver.js.map +0 -1
- package/lib/cjs/exports.js +0 -7
- package/lib/cjs/exports.js.map +0 -1
- package/lib/cjs/index.js +0 -15
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/interfaces/TypeGraphQLSettings.js +0 -3
- package/lib/cjs/interfaces/TypeGraphQLSettings.js.map +0 -1
- package/lib/cjs/interfaces/interfaces.js +0 -5
- package/lib/cjs/interfaces/interfaces.js.map +0 -1
- package/lib/cjs/middlewares/ContextMiddleware.js +0 -9
- package/lib/cjs/middlewares/ContextMiddleware.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/services/TypeGraphQLService.js +0 -121
- package/lib/cjs/services/TypeGraphQLService.js.map +0 -1
- package/lib/esm/package.json +0 -3
- package/lib/esm/services/TypeGraphQLService.js +0 -118
- package/lib/esm/services/TypeGraphQLService.js.map +0 -1
- package/lib/types/services/TypeGraphQLService.d.ts +0 -36
- package/lib/types-esm/TypeGraphQLModule.d.ts +0 -16
- package/lib/types-esm/constants/constants.d.ts +0 -1
- package/lib/types-esm/decorators/resolver.d.ts +0 -16
- package/lib/types-esm/exports.d.ts +0 -1
- package/lib/types-esm/index.d.ts +0 -11
- package/lib/types-esm/interfaces/TypeGraphQLSettings.d.ts +0 -6
- package/lib/types-esm/interfaces/interfaces.d.ts +0 -14
- package/lib/types-esm/middlewares/ContextMiddleware.d.ts +0 -7
- package/lib/types-esm/services/TypeGraphQLService.d.ts +0 -36
|
@@ -1,41 +1,49 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import "./interfaces/interfaces.js";
|
|
3
|
+
import { isClass } from "@tsed/core";
|
|
2
4
|
import { Configuration, Inject, InjectorService, Module } from "@tsed/di";
|
|
3
|
-
import {
|
|
5
|
+
import { buildSchema } from "type-graphql";
|
|
6
|
+
import { RESOLVERS_PROVIDERS } from "./constants/constants.js";
|
|
7
|
+
import { ContextMiddleware } from "./middlewares/ContextMiddleware.js";
|
|
4
8
|
/**
|
|
5
9
|
* @ignore
|
|
6
10
|
*/
|
|
7
11
|
let TypeGraphQLModule = class TypeGraphQLModule {
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
async $alterApolloSettings(settings) {
|
|
13
|
+
const { resolvers: initialResolvers = [], buildSchemaOptions = {}, ...serverOptions } = settings;
|
|
14
|
+
const resolvers = this.getResolvers(settings.id, [...initialResolvers, ...(buildSchemaOptions.resolvers || [])]);
|
|
15
|
+
serverOptions.schema = await buildSchema({
|
|
16
|
+
container: this.injector,
|
|
17
|
+
...buildSchemaOptions,
|
|
18
|
+
resolvers,
|
|
19
|
+
globalMiddlewares: [ContextMiddleware, ...(buildSchemaOptions.globalMiddlewares || [])]
|
|
20
|
+
});
|
|
21
|
+
return serverOptions;
|
|
10
22
|
}
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
getResolvers(id, resolvers) {
|
|
24
|
+
const globalResolvers = this.injector
|
|
25
|
+
.getProviders(RESOLVERS_PROVIDERS)
|
|
26
|
+
.filter((provider) => {
|
|
27
|
+
const opts = provider.store.get("graphql");
|
|
28
|
+
return !opts?.id || opts?.id === id;
|
|
29
|
+
})
|
|
30
|
+
.map((provider) => {
|
|
31
|
+
return provider.useClass;
|
|
32
|
+
});
|
|
33
|
+
return resolvers
|
|
34
|
+
.map((resolver) => {
|
|
35
|
+
if (!(this.injector.has(resolver) || !isClass(resolver))) {
|
|
36
|
+
this.injector
|
|
37
|
+
.addProvider(resolver, {
|
|
38
|
+
useClass: resolver
|
|
39
|
+
})
|
|
40
|
+
.invoke(resolver);
|
|
41
|
+
}
|
|
42
|
+
return resolver;
|
|
43
|
+
})
|
|
44
|
+
.concat(globalResolvers);
|
|
33
45
|
}
|
|
34
46
|
};
|
|
35
|
-
__decorate([
|
|
36
|
-
Inject(),
|
|
37
|
-
__metadata("design:type", TypeGraphQLService)
|
|
38
|
-
], TypeGraphQLModule.prototype, "service", void 0);
|
|
39
47
|
__decorate([
|
|
40
48
|
Inject(),
|
|
41
49
|
__metadata("design:type", InjectorService)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeGraphQLModule.js","sourceRoot":"","sources":["../../src/TypeGraphQL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index.js
CHANGED
|
@@ -7,6 +7,5 @@ export * from "./exports.js";
|
|
|
7
7
|
export * from "./interfaces/interfaces.js";
|
|
8
8
|
export * from "./interfaces/TypeGraphQLSettings.js";
|
|
9
9
|
export * from "./middlewares/ContextMiddleware.js";
|
|
10
|
-
export * from "./services/TypeGraphQLService.js";
|
|
11
10
|
export * from "./TypeGraphQLModule.js";
|
|
12
11
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qCAAqC,CAAC;AACpD,cAAc,oCAAoC,CAAC;AACnD,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qCAAqC,CAAC;AACpD,cAAc,oCAAoC,CAAC;AACnD,cAAc,wBAAwB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=interfaces.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const ContextMiddleware = (
|
|
3
|
-
|
|
1
|
+
import { runInContext, useContext } from "@tsed/di";
|
|
2
|
+
export const ContextMiddleware = (action, next) => {
|
|
3
|
+
const $ctx = useContext(action.context?.req?.$ctx);
|
|
4
|
+
return runInContext($ctx, next);
|
|
4
5
|
};
|
|
5
6
|
//# sourceMappingURL=ContextMiddleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/ContextMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ContextMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/ContextMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,YAAY,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAGlE,MAAM,CAAC,MAAM,iBAAiB,GAA2C,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;IACxF,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IACnD,OAAO,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAClC,CAAC,CAAC"}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
+
import "./interfaces/interfaces.js";
|
|
2
|
+
import { AlterApolloSettings, ApolloSettingsWithID } from "@tsed/apollo";
|
|
3
|
+
import { Type } from "@tsed/core";
|
|
1
4
|
import { Configuration, InjectorService } from "@tsed/di";
|
|
2
|
-
import { TypeGraphQLSettings } from "./interfaces/interfaces.js";
|
|
3
|
-
import { TypeGraphQLService } from "./services/TypeGraphQLService.js";
|
|
4
5
|
/**
|
|
5
6
|
* @ignore
|
|
6
7
|
*/
|
|
7
|
-
export declare class TypeGraphQLModule {
|
|
8
|
-
protected service: TypeGraphQLService;
|
|
8
|
+
export declare class TypeGraphQLModule implements AlterApolloSettings {
|
|
9
9
|
protected injector: InjectorService;
|
|
10
10
|
protected configuration: Configuration;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} | undefined;
|
|
14
|
-
$onRoutesInit(): Promise<any> | void;
|
|
15
|
-
$afterListen(): Promise<any> | void;
|
|
11
|
+
$alterApolloSettings(settings: ApolloSettingsWithID): Promise<ApolloSettingsWithID>;
|
|
12
|
+
protected getResolvers(id: string, resolvers: Type<any>[]): Type<any>[];
|
|
16
13
|
}
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import { ClassType } from "type-graphql";
|
|
2
|
-
|
|
3
|
-
export interface ResolverControllerOptions extends AbstractClassOptions {
|
|
2
|
+
export interface ResolverControllerOptions {
|
|
4
3
|
id?: string;
|
|
5
4
|
}
|
|
6
|
-
export declare function ResolverController(
|
|
7
|
-
export declare function ResolverController(
|
|
8
|
-
export declare function ResolverController(typeFunc:
|
|
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;
|
|
9
8
|
export declare function ResolverController(objectType: ClassType, options?: ResolverControllerOptions): ClassDecorator;
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated Use ResolverController instead
|
|
12
|
-
*/
|
|
13
|
-
export declare function ResolverService(): ClassDecorator;
|
|
14
|
-
export declare function ResolverService(options: AbstractClassOptions): ClassDecorator;
|
|
15
|
-
export declare function ResolverService(typeFunc: ClassTypeResolver, options?: AbstractClassOptions): ClassDecorator;
|
|
16
|
-
export declare function ResolverService(objectType: ClassType, options?: AbstractClassOptions): ClassDecorator;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -7,5 +7,4 @@ export * from "./exports.js";
|
|
|
7
7
|
export * from "./interfaces/interfaces.js";
|
|
8
8
|
export * from "./interfaces/TypeGraphQLSettings.js";
|
|
9
9
|
export * from "./middlewares/ContextMiddleware.js";
|
|
10
|
-
export * from "./services/TypeGraphQLService.js";
|
|
11
10
|
export * from "./TypeGraphQLModule.js";
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { BuildSchemaOptions } from "type-graphql";
|
|
3
|
-
export interface TypeGraphQLSettings extends ApolloSettings {
|
|
4
|
-
buildSchemaOptions?: Partial<BuildSchemaOptions>;
|
|
5
|
-
serverConfig?: ApolloConfig;
|
|
6
|
-
}
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ApolloSettings as AS } from "@tsed/apollo";
|
|
2
|
+
import { BuildSchemaOptions } from "type-graphql";
|
|
2
3
|
declare global {
|
|
3
4
|
namespace TsED {
|
|
5
|
+
interface ApolloSettings {
|
|
6
|
+
buildSchemaOptions?: Partial<BuildSchemaOptions>;
|
|
7
|
+
}
|
|
4
8
|
interface Configuration {
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use apollo instead
|
|
11
|
+
*/
|
|
5
12
|
graphql: {
|
|
6
|
-
[key: string]:
|
|
13
|
+
[key: string]: AS;
|
|
7
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use apollo instead
|
|
17
|
+
*/
|
|
8
18
|
typegraphql: {
|
|
9
|
-
[key: string]:
|
|
19
|
+
[key: string]: AS;
|
|
10
20
|
};
|
|
11
21
|
}
|
|
12
22
|
}
|
|
13
23
|
}
|
|
14
|
-
export * from "./TypeGraphQLSettings.js";
|
package/package.json
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
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": "
|
|
5
|
-
"version": "8.0.0-alpha.
|
|
4
|
+
"type": "module",
|
|
5
|
+
"version": "8.0.0-alpha.11",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
|
-
"main": "./lib/
|
|
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
|
-
"
|
|
15
|
-
"default": "./lib/cjs/index.js"
|
|
14
|
+
"default": "./lib/esm/index.js"
|
|
16
15
|
}
|
|
17
16
|
},
|
|
18
17
|
"scripts": {
|
|
@@ -25,29 +24,34 @@
|
|
|
25
24
|
"test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
|
|
26
25
|
},
|
|
27
26
|
"dependencies": {
|
|
28
|
-
"@tsed/apollo": "8.0.0-alpha.
|
|
29
|
-
"tslib": "2.
|
|
27
|
+
"@tsed/apollo": "8.0.0-alpha.11",
|
|
28
|
+
"tslib": "2.7.0"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
|
-
"@
|
|
33
|
-
"@tsed/
|
|
34
|
-
"@tsed/
|
|
35
|
-
"@tsed/
|
|
31
|
+
"@graphql-yoga/subscription": "5.0.1",
|
|
32
|
+
"@tsed/barrels": "8.0.0-alpha.11",
|
|
33
|
+
"@tsed/common": "8.0.0-alpha.11",
|
|
34
|
+
"@tsed/core": "8.0.0-alpha.11",
|
|
35
|
+
"@tsed/platform-express": "8.0.0-alpha.11",
|
|
36
|
+
"@tsed/typescript": "8.0.0-alpha.11",
|
|
36
37
|
"@types/graphql": "^14.5.0",
|
|
37
38
|
"class-validator": "~0.14.1",
|
|
38
39
|
"cross-env": "^7.0.3",
|
|
39
|
-
"eslint": "
|
|
40
|
-
"graphql
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
40
|
+
"eslint": "9.12.0",
|
|
41
|
+
"graphql": "16.9.0",
|
|
42
|
+
"graphql-passport": "^0.6.8",
|
|
43
|
+
"graphql-scalars": "1.23.0",
|
|
44
|
+
"ts-node": "10.9.2",
|
|
45
|
+
"type-graphql": ">=2.0.0-rc.2",
|
|
46
|
+
"typescript": "5.4.5",
|
|
47
|
+
"vitest": "2.1.2"
|
|
44
48
|
},
|
|
45
49
|
"peerDependencies": {
|
|
46
|
-
"apollo-
|
|
47
|
-
"apollo-datasource-rest": ">=3.0.0",
|
|
50
|
+
"@apollo/datasource-rest": ">=6.2.2",
|
|
48
51
|
"class-validator": ">=0.13.1",
|
|
49
|
-
"graphql": ">=
|
|
50
|
-
"
|
|
52
|
+
"graphql": ">=16.0.0",
|
|
53
|
+
"graphql-scalars": ">=1.23.0",
|
|
54
|
+
"type-graphql": ">=2.0.0-rc.2"
|
|
51
55
|
},
|
|
52
56
|
"repository": "https://github.com/tsedio/tsed",
|
|
53
57
|
"bugs": {
|
package/readme.md
CHANGED
|
@@ -33,59 +33,59 @@ GraphQL is a query language for APIs and a runtime for fulfilling those queries
|
|
|
33
33
|
## Feature
|
|
34
34
|
|
|
35
35
|
Currently, `@tsed/typegraphql` allows you to configure a graphql server in your project.
|
|
36
|
-
This package use [
|
|
36
|
+
This package use [`@apollo/server`](https://www.apollographql.com/) to create GraphQL server and [`type-graphql`](https://19majkel94.github.io/type-graphql/)
|
|
37
37
|
for the decorators.
|
|
38
38
|
|
|
39
39
|
## Installation
|
|
40
40
|
|
|
41
41
|
To begin, install the TypeGraphQL module for TS.ED:
|
|
42
42
|
|
|
43
|
+
Express.js:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install --save @tsed/apollo graphql type-graphql @apollo/server @apollo/datasource-rest graphql-scalars
|
|
47
|
+
npm install --save-dev apollo-server-testing
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Koa.js
|
|
51
|
+
|
|
43
52
|
```bash
|
|
44
|
-
npm install --save @tsed/
|
|
45
|
-
npm install --save
|
|
46
|
-
npm install --save-dev apollo-server-testing
|
|
53
|
+
npm install --save @tsed/apollo graphql type-graphql @apollo/server @as-integration/koa @apollo/datasource-rest graphql-scalars
|
|
54
|
+
npm install --save-dev apollo-server-testing
|
|
47
55
|
```
|
|
48
56
|
|
|
49
57
|
Now, we can configure the Ts.ED server by importing `@tsed/typegraphql` in your Server:
|
|
50
58
|
|
|
51
59
|
```typescript
|
|
52
|
-
import {Configuration} from "@tsed/
|
|
60
|
+
import {Configuration} from "@tsed/di";
|
|
61
|
+
import "@tsed/platform-express";
|
|
53
62
|
import "@tsed/typegraphql";
|
|
63
|
+
import "./resolvers/index"; // barrel file with all resolvers
|
|
54
64
|
|
|
55
65
|
@Configuration({
|
|
56
|
-
|
|
66
|
+
apollo: {
|
|
57
67
|
server1: {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
export class Server {}
|
|
63
|
-
```
|
|
68
|
+
// GraphQL server configuration
|
|
69
|
+
// See options descriptions on https://www.apollographql.com/docs/apollo-server/api/apollo-server.html
|
|
70
|
+
path: "/",
|
|
71
|
+
playground: true // enable playground GraphQL IDE. Set false to use Apollo Studio
|
|
64
72
|
|
|
65
|
-
|
|
73
|
+
// resolvers?: (Function | string)[];
|
|
74
|
+
// dataSources?: Function;
|
|
75
|
+
// server?: (config: Config) => ApolloServer;
|
|
66
76
|
|
|
67
|
-
|
|
77
|
+
// plugins: []
|
|
78
|
+
// middlewareOptions?: ServerRegistration;
|
|
68
79
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
@Service()
|
|
75
|
-
export class UsersService implements AfterRoutesInit {
|
|
76
|
-
private server: ApolloServer;
|
|
77
|
-
|
|
78
|
-
@Inject()
|
|
79
|
-
typeGraphQLService: TypeGraphQLService;
|
|
80
|
-
|
|
81
|
-
$afterRoutesInit() {
|
|
82
|
-
this.server = this.typeGraphQLService.get("server1");
|
|
80
|
+
// type-graphql
|
|
81
|
+
// See options descriptions on https://19majkel94.github.io/type-graphql/
|
|
82
|
+
// buildSchemaOptions?: Partial<BuildSchemaOptions>;
|
|
83
|
+
}
|
|
83
84
|
}
|
|
84
|
-
}
|
|
85
|
+
})
|
|
86
|
+
export class Server {}
|
|
85
87
|
```
|
|
86
88
|
|
|
87
|
-
For more information about ApolloServer look his documentation [here](https://www.apollographql.com/docs/apollo-server/api/apollo-server.html);
|
|
88
|
-
|
|
89
89
|
## Type-graphql
|
|
90
90
|
|
|
91
91
|
### Types
|
package/vitest.config.mts
CHANGED
package/.nycrc
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"include": [
|
|
3
|
-
"src/**/*.ts"
|
|
4
|
-
],
|
|
5
|
-
"exclude": [
|
|
6
|
-
"**/*.d.ts",
|
|
7
|
-
"**/*.spec.ts",
|
|
8
|
-
"node_modules",
|
|
9
|
-
"**/interfaces/**",
|
|
10
|
-
"**/index.ts"
|
|
11
|
-
],
|
|
12
|
-
"extension": [
|
|
13
|
-
".ts"
|
|
14
|
-
],
|
|
15
|
-
"require": [],
|
|
16
|
-
"reporter": [
|
|
17
|
-
"text-summary",
|
|
18
|
-
"html",
|
|
19
|
-
"lcov",
|
|
20
|
-
"json"
|
|
21
|
-
],
|
|
22
|
-
"check-coverage": true,
|
|
23
|
-
"statements": 99.14,
|
|
24
|
-
"branches": 70.45,
|
|
25
|
-
"functions": 100,
|
|
26
|
-
"lines": 100
|
|
27
|
-
}
|
|
@@ -1,54 +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 di_1 = require("@tsed/di");
|
|
6
|
-
const TypeGraphQLService_js_1 = require("./services/TypeGraphQLService.js");
|
|
7
|
-
/**
|
|
8
|
-
* @ignore
|
|
9
|
-
*/
|
|
10
|
-
let TypeGraphQLModule = class TypeGraphQLModule {
|
|
11
|
-
get settings() {
|
|
12
|
-
return this.configuration.get("graphql") || this.configuration.get("typegraphql");
|
|
13
|
-
}
|
|
14
|
-
$onRoutesInit() {
|
|
15
|
-
const { settings } = this;
|
|
16
|
-
if (settings) {
|
|
17
|
-
const promises = Object.entries(settings).map(([key, options]) => {
|
|
18
|
-
return this.service.createServer(key, options);
|
|
19
|
-
});
|
|
20
|
-
return Promise.all(promises);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
$afterListen() {
|
|
24
|
-
const host = this.configuration.getBestHost();
|
|
25
|
-
const displayLog = (key, path) => {
|
|
26
|
-
const url = typeof host.port === "number" ? `${host.protocol}://${host.address}:${host.port}` : "";
|
|
27
|
-
this.injector.logger.info(`[${key}] GraphQL server is available on ${url}/${path.replace(/^\//, "")}`);
|
|
28
|
-
};
|
|
29
|
-
const { settings } = this;
|
|
30
|
-
if (settings) {
|
|
31
|
-
Object.entries(settings).map(([key, options]) => {
|
|
32
|
-
const { path } = options;
|
|
33
|
-
displayLog(key, path);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
tslib_1.__decorate([
|
|
39
|
-
(0, di_1.Inject)(),
|
|
40
|
-
tslib_1.__metadata("design:type", TypeGraphQLService_js_1.TypeGraphQLService)
|
|
41
|
-
], TypeGraphQLModule.prototype, "service", void 0);
|
|
42
|
-
tslib_1.__decorate([
|
|
43
|
-
(0, di_1.Inject)(),
|
|
44
|
-
tslib_1.__metadata("design:type", di_1.InjectorService)
|
|
45
|
-
], TypeGraphQLModule.prototype, "injector", void 0);
|
|
46
|
-
tslib_1.__decorate([
|
|
47
|
-
(0, di_1.Configuration)(),
|
|
48
|
-
tslib_1.__metadata("design:type", Object)
|
|
49
|
-
], TypeGraphQLModule.prototype, "configuration", void 0);
|
|
50
|
-
TypeGraphQLModule = tslib_1.__decorate([
|
|
51
|
-
(0, di_1.Module)()
|
|
52
|
-
], TypeGraphQLModule);
|
|
53
|
-
exports.TypeGraphQLModule = TypeGraphQLModule;
|
|
54
|
-
//# sourceMappingURL=TypeGraphQLModule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TypeGraphQLModule.js","sourceRoot":"","sources":["../../src/TypeGraphQLModule.ts"],"names":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C,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE;gBAC9C,MAAM,EAAC,IAAI,EAAC,GAAG,OAAO,CAAC;gBAEvB,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YACxB,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;CACF,CAAA;AA3CC;IAAC,IAAA,WAAM,GAAE;sCACU,0CAAkB;kDAAC;AAEtC;IAAC,IAAA,WAAM,GAAE;sCACW,oBAAe;mDAAC;AAEpC;IAAC,IAAA,kBAAa,GAAE;;wDACuB;AAR5B,iBAAiB;IAD7B,IAAA,WAAM,GAAE;GACI,iBAAiB,CA4C7B;AA5CY,8CAAiB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,mBAAmB,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResolverService = 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
|
-
/**
|
|
33
|
-
* @deprecated Use ResolverController instead
|
|
34
|
-
*/
|
|
35
|
-
function ResolverService(...args) {
|
|
36
|
-
return ResolverController(...args);
|
|
37
|
-
}
|
|
38
|
-
exports.ResolverService = ResolverService;
|
|
39
|
-
//# 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;AAEjD,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;AASD;;GAEG;AACH,SAAgB,eAAe,CAAC,GAAG,IAAW;IAC5C,OAAQ,kBAA0B,CAAC,GAAG,IAAI,CAAC,CAAC;AAC9C,CAAC;AAFD,0CAEC"}
|
package/lib/cjs/exports.js
DELETED
|
@@ -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
|
package/lib/cjs/exports.js.map
DELETED
|
@@ -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,15 +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("./services/TypeGraphQLService.js"), exports);
|
|
14
|
-
tslib_1.__exportStar(require("./TypeGraphQLModule.js"), exports);
|
|
15
|
-
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
DELETED
|
@@ -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,2EAAiD;AACjD,iEAAuC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TypeGraphQLSettings.js","sourceRoot":"","sources":["../../../src/interfaces/TypeGraphQLSettings.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":";;;AAWA,mEAAyC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContextMiddleware = void 0;
|
|
4
|
-
const common_1 = require("@tsed/common");
|
|
5
|
-
const ContextMiddleware = (_, next) => {
|
|
6
|
-
return (0, common_1.runInContext)((0, common_1.getContext)(), next);
|
|
7
|
-
};
|
|
8
|
-
exports.ContextMiddleware = ContextMiddleware;
|
|
9
|
-
//# sourceMappingURL=ContextMiddleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/ContextMiddleware.ts"],"names":[],"mappings":";;;AAAA,yCAAuE;AAGhE,MAAM,iBAAiB,GAAiD,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE;IACzF,OAAO,IAAA,qBAAY,EAAC,IAAA,mBAAU,GAAE,EAAE,IAAI,CAAC,CAAC;AAC1C,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B"}
|
package/lib/cjs/package.json
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TypeGraphQLService = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const apollo_1 = require("@tsed/apollo");
|
|
6
|
-
const core_1 = require("@tsed/core");
|
|
7
|
-
const di_1 = require("@tsed/di");
|
|
8
|
-
const logger_1 = require("@tsed/logger");
|
|
9
|
-
const type_graphql_1 = require("type-graphql");
|
|
10
|
-
const constants_js_1 = require("../constants/constants.js");
|
|
11
|
-
const ContextMiddleware_js_1 = require("../middlewares/ContextMiddleware.js");
|
|
12
|
-
const getKey = (id) => `typegraphql-${id}`;
|
|
13
|
-
let TypeGraphQLService = class TypeGraphQLService {
|
|
14
|
-
/**
|
|
15
|
-
* Get an instance of ApolloServer from his id
|
|
16
|
-
* @returns ApolloServer
|
|
17
|
-
*/
|
|
18
|
-
get(id = "default") {
|
|
19
|
-
return this.apolloService.get(getKey(id));
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {string} id
|
|
24
|
-
* @returns {boolean}
|
|
25
|
-
*/
|
|
26
|
-
has(id = "default") {
|
|
27
|
-
return this.apolloService.has(getKey(id));
|
|
28
|
-
}
|
|
29
|
-
async createServer(id, settings) {
|
|
30
|
-
if (!this.has(id)) {
|
|
31
|
-
try {
|
|
32
|
-
const { dataSources, resolvers: initialResolvers = [], buildSchemaOptions = {}, serverConfig = {}, ...serverOptions } = settings;
|
|
33
|
-
const resolvers = this.getResolvers(id, [...initialResolvers, ...(buildSchemaOptions.resolvers || [])]);
|
|
34
|
-
const schema = await this.createSchema({
|
|
35
|
-
container: this.injector,
|
|
36
|
-
...buildSchemaOptions,
|
|
37
|
-
resolvers,
|
|
38
|
-
globalMiddlewares: [ContextMiddleware_js_1.ContextMiddleware, ...(buildSchemaOptions.globalMiddlewares || [])]
|
|
39
|
-
});
|
|
40
|
-
return await this.apolloService.createServer(getKey(id), {
|
|
41
|
-
...serverOptions,
|
|
42
|
-
...serverConfig,
|
|
43
|
-
resolvers,
|
|
44
|
-
dataSources: () => {
|
|
45
|
-
return {
|
|
46
|
-
...(dataSources ? dataSources() : {}),
|
|
47
|
-
...(serverConfig.dataSources ? serverConfig.dataSources() : {})
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
schema
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
catch (er) {
|
|
54
|
-
/* istanbul ignore next */
|
|
55
|
-
this.logger.error({
|
|
56
|
-
event: "TYPEGRAPHQL_BOOTSTRAP_ERROR",
|
|
57
|
-
error_name: er.name,
|
|
58
|
-
message: er.message,
|
|
59
|
-
stack: er.stack
|
|
60
|
-
});
|
|
61
|
-
/* istanbul ignore next */
|
|
62
|
-
process.exit(-1);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return this.get(id);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Create a new type-graphql Schema and bind it with Ts.ED injector.
|
|
69
|
-
* @param buildSchemaOptions
|
|
70
|
-
*/
|
|
71
|
-
createSchema(buildSchemaOptions) {
|
|
72
|
-
return (0, type_graphql_1.buildSchema)(buildSchemaOptions);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Get an instance of GraphQL schema from his id
|
|
76
|
-
* @returns GraphQLSchema
|
|
77
|
-
*/
|
|
78
|
-
getSchema(id = "default") {
|
|
79
|
-
return this.apolloService.getSchema(getKey(id));
|
|
80
|
-
}
|
|
81
|
-
getResolvers(id, resolvers) {
|
|
82
|
-
const globalResolvers = this.injector
|
|
83
|
-
.getProviders(constants_js_1.RESOLVERS_PROVIDERS)
|
|
84
|
-
.filter((provider) => {
|
|
85
|
-
const opts = provider.store.get("graphql");
|
|
86
|
-
return !opts?.id || opts?.id === id;
|
|
87
|
-
})
|
|
88
|
-
.map((provider) => {
|
|
89
|
-
return provider.useClass;
|
|
90
|
-
});
|
|
91
|
-
return resolvers
|
|
92
|
-
.map((resolver) => {
|
|
93
|
-
if (!(this.injector.has(resolver) || !(0, core_1.isClass)(resolver))) {
|
|
94
|
-
this.injector
|
|
95
|
-
.addProvider(resolver, {
|
|
96
|
-
useClass: resolver
|
|
97
|
-
})
|
|
98
|
-
.invoke(resolver);
|
|
99
|
-
}
|
|
100
|
-
return resolver;
|
|
101
|
-
})
|
|
102
|
-
.concat(globalResolvers);
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
tslib_1.__decorate([
|
|
106
|
-
(0, di_1.Inject)(),
|
|
107
|
-
tslib_1.__metadata("design:type", di_1.InjectorService)
|
|
108
|
-
], TypeGraphQLService.prototype, "injector", void 0);
|
|
109
|
-
tslib_1.__decorate([
|
|
110
|
-
(0, di_1.Inject)(),
|
|
111
|
-
tslib_1.__metadata("design:type", apollo_1.ApolloService)
|
|
112
|
-
], TypeGraphQLService.prototype, "apolloService", void 0);
|
|
113
|
-
tslib_1.__decorate([
|
|
114
|
-
(0, di_1.Inject)(),
|
|
115
|
-
tslib_1.__metadata("design:type", logger_1.Logger)
|
|
116
|
-
], TypeGraphQLService.prototype, "logger", void 0);
|
|
117
|
-
TypeGraphQLService = tslib_1.__decorate([
|
|
118
|
-
(0, di_1.Injectable)()
|
|
119
|
-
], TypeGraphQLService);
|
|
120
|
-
exports.TypeGraphQLService = TypeGraphQLService;
|
|
121
|
-
//# sourceMappingURL=TypeGraphQLService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TypeGraphQLService.js","sourceRoot":"","sources":["../../../src/services/TypeGraphQLService.ts"],"names":[],"mappings":";;;;AAAA,yCAA2C;AAC3C,qCAAyC;AACzC,iCAA6D;AAC7D,yCAAoC;AAGpC,+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E,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;AA9GC;IAAC,IAAA,WAAM,GAAE;sCACW,oBAAe;oDAAC;AAEpC;IAAC,IAAA,WAAM,GAAE;sCACgB,sBAAa;yDAAC;AAEvC;IAAC,IAAA,WAAM,GAAE;sCACS,eAAM;kDAAC;AARd,kBAAkB;IAD9B,IAAA,eAAU,GAAE;GACA,kBAAkB,CA+G9B;AA/GY,gDAAkB"}
|
package/lib/esm/package.json
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { ApolloService } from "@tsed/apollo";
|
|
3
|
-
import { isClass } from "@tsed/core";
|
|
4
|
-
import { Inject, Injectable, InjectorService } from "@tsed/di";
|
|
5
|
-
import { Logger } from "@tsed/logger";
|
|
6
|
-
import { buildSchema } from "type-graphql";
|
|
7
|
-
import { RESOLVERS_PROVIDERS } from "../constants/constants.js";
|
|
8
|
-
import { ContextMiddleware } from "../middlewares/ContextMiddleware.js";
|
|
9
|
-
const getKey = (id) => `typegraphql-${id}`;
|
|
10
|
-
let TypeGraphQLService = class TypeGraphQLService {
|
|
11
|
-
/**
|
|
12
|
-
* Get an instance of ApolloServer from his id
|
|
13
|
-
* @returns ApolloServer
|
|
14
|
-
*/
|
|
15
|
-
get(id = "default") {
|
|
16
|
-
return this.apolloService.get(getKey(id));
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param {string} id
|
|
21
|
-
* @returns {boolean}
|
|
22
|
-
*/
|
|
23
|
-
has(id = "default") {
|
|
24
|
-
return this.apolloService.has(getKey(id));
|
|
25
|
-
}
|
|
26
|
-
async createServer(id, settings) {
|
|
27
|
-
if (!this.has(id)) {
|
|
28
|
-
try {
|
|
29
|
-
const { dataSources, resolvers: initialResolvers = [], buildSchemaOptions = {}, serverConfig = {}, ...serverOptions } = settings;
|
|
30
|
-
const resolvers = this.getResolvers(id, [...initialResolvers, ...(buildSchemaOptions.resolvers || [])]);
|
|
31
|
-
const schema = await this.createSchema({
|
|
32
|
-
container: this.injector,
|
|
33
|
-
...buildSchemaOptions,
|
|
34
|
-
resolvers,
|
|
35
|
-
globalMiddlewares: [ContextMiddleware, ...(buildSchemaOptions.globalMiddlewares || [])]
|
|
36
|
-
});
|
|
37
|
-
return await this.apolloService.createServer(getKey(id), {
|
|
38
|
-
...serverOptions,
|
|
39
|
-
...serverConfig,
|
|
40
|
-
resolvers,
|
|
41
|
-
dataSources: () => {
|
|
42
|
-
return {
|
|
43
|
-
...(dataSources ? dataSources() : {}),
|
|
44
|
-
...(serverConfig.dataSources ? serverConfig.dataSources() : {})
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
schema
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
catch (er) {
|
|
51
|
-
/* istanbul ignore next */
|
|
52
|
-
this.logger.error({
|
|
53
|
-
event: "TYPEGRAPHQL_BOOTSTRAP_ERROR",
|
|
54
|
-
error_name: er.name,
|
|
55
|
-
message: er.message,
|
|
56
|
-
stack: er.stack
|
|
57
|
-
});
|
|
58
|
-
/* istanbul ignore next */
|
|
59
|
-
process.exit(-1);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return this.get(id);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Create a new type-graphql Schema and bind it with Ts.ED injector.
|
|
66
|
-
* @param buildSchemaOptions
|
|
67
|
-
*/
|
|
68
|
-
createSchema(buildSchemaOptions) {
|
|
69
|
-
return buildSchema(buildSchemaOptions);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Get an instance of GraphQL schema from his id
|
|
73
|
-
* @returns GraphQLSchema
|
|
74
|
-
*/
|
|
75
|
-
getSchema(id = "default") {
|
|
76
|
-
return this.apolloService.getSchema(getKey(id));
|
|
77
|
-
}
|
|
78
|
-
getResolvers(id, resolvers) {
|
|
79
|
-
const globalResolvers = this.injector
|
|
80
|
-
.getProviders(RESOLVERS_PROVIDERS)
|
|
81
|
-
.filter((provider) => {
|
|
82
|
-
const opts = provider.store.get("graphql");
|
|
83
|
-
return !opts?.id || opts?.id === id;
|
|
84
|
-
})
|
|
85
|
-
.map((provider) => {
|
|
86
|
-
return provider.useClass;
|
|
87
|
-
});
|
|
88
|
-
return resolvers
|
|
89
|
-
.map((resolver) => {
|
|
90
|
-
if (!(this.injector.has(resolver) || !isClass(resolver))) {
|
|
91
|
-
this.injector
|
|
92
|
-
.addProvider(resolver, {
|
|
93
|
-
useClass: resolver
|
|
94
|
-
})
|
|
95
|
-
.invoke(resolver);
|
|
96
|
-
}
|
|
97
|
-
return resolver;
|
|
98
|
-
})
|
|
99
|
-
.concat(globalResolvers);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
__decorate([
|
|
103
|
-
Inject(),
|
|
104
|
-
__metadata("design:type", InjectorService)
|
|
105
|
-
], TypeGraphQLService.prototype, "injector", void 0);
|
|
106
|
-
__decorate([
|
|
107
|
-
Inject(),
|
|
108
|
-
__metadata("design:type", ApolloService)
|
|
109
|
-
], TypeGraphQLService.prototype, "apolloService", void 0);
|
|
110
|
-
__decorate([
|
|
111
|
-
Inject(),
|
|
112
|
-
__metadata("design:type", Logger)
|
|
113
|
-
], TypeGraphQLService.prototype, "logger", void 0);
|
|
114
|
-
TypeGraphQLService = __decorate([
|
|
115
|
-
Injectable()
|
|
116
|
-
], TypeGraphQLService);
|
|
117
|
-
export { TypeGraphQLService };
|
|
118
|
-
//# sourceMappingURL=TypeGraphQLService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TypeGraphQLService.js","sourceRoot":"","sources":["../../../src/services/TypeGraphQLService.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAC,OAAO,EAAO,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAGpC,OAAO,EAAC,WAAW,EAAqB,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAC,mBAAmB,EAAC,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAC,iBAAiB,EAAC,MAAM,qCAAqC,CAAC;AAEtE,MAAM,MAAM,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,eAAe,EAAE,EAAE,CAAC;AAG5C,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAU7B;;;OAGG;IACH,GAAG,CAAC,KAAa,SAAS;QACxB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,KAAa,SAAS;QACxB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,EAAU,EAAE,QAA6B;QA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AO,QAAQ,CAAC;QAClB,CAAC,CAAC;aACD,MAAM,CAAC,eAAe,CAAC,CAAC;IAC7B,CAAC;CACF,CAAA;AA9GC;IAAC,MAAM,EAAE;8BACW,eAAe;oDAAC;AAEpC;IAAC,MAAM,EAAE;8BACgB,aAAa;yDAAC;AAEvC;IAAC,MAAM,EAAE;8BACS,MAAM;kDAAC;AARd,kBAAkB;IAD9B,UAAU,EAAE;GACA,kBAAkB,CA+G9B;SA/GY,kBAAkB"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ApolloService } from "@tsed/apollo";
|
|
2
|
-
import { Type } from "@tsed/core";
|
|
3
|
-
import { InjectorService } from "@tsed/di";
|
|
4
|
-
import { Logger } from "@tsed/logger";
|
|
5
|
-
import { ApolloServerBase } from "apollo-server-core";
|
|
6
|
-
import { GraphQLSchema } from "graphql";
|
|
7
|
-
import { BuildSchemaOptions } from "type-graphql";
|
|
8
|
-
import { TypeGraphQLSettings } from "../interfaces/interfaces.js";
|
|
9
|
-
export declare class TypeGraphQLService {
|
|
10
|
-
protected injector: InjectorService;
|
|
11
|
-
protected apolloService: ApolloService;
|
|
12
|
-
protected logger: Logger;
|
|
13
|
-
/**
|
|
14
|
-
* Get an instance of ApolloServer from his id
|
|
15
|
-
* @returns ApolloServer
|
|
16
|
-
*/
|
|
17
|
-
get(id?: string): ApolloServerBase | undefined;
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param {string} id
|
|
21
|
-
* @returns {boolean}
|
|
22
|
-
*/
|
|
23
|
-
has(id?: string): boolean;
|
|
24
|
-
createServer(id: string, settings: TypeGraphQLSettings): Promise<ApolloServerBase<any>>;
|
|
25
|
-
/**
|
|
26
|
-
* Create a new type-graphql Schema and bind it with Ts.ED injector.
|
|
27
|
-
* @param buildSchemaOptions
|
|
28
|
-
*/
|
|
29
|
-
createSchema(buildSchemaOptions: BuildSchemaOptions): Promise<GraphQLSchema>;
|
|
30
|
-
/**
|
|
31
|
-
* Get an instance of GraphQL schema from his id
|
|
32
|
-
* @returns GraphQLSchema
|
|
33
|
-
*/
|
|
34
|
-
getSchema(id?: string): GraphQLSchema | undefined;
|
|
35
|
-
protected getResolvers(id: string, resolvers: Type<any>[]): Type<any>[];
|
|
36
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Configuration, InjectorService } from "@tsed/di";
|
|
2
|
-
import { TypeGraphQLSettings } from "./interfaces/interfaces.js";
|
|
3
|
-
import { TypeGraphQLService } from "./services/TypeGraphQLService.js";
|
|
4
|
-
/**
|
|
5
|
-
* @ignore
|
|
6
|
-
*/
|
|
7
|
-
export declare class TypeGraphQLModule {
|
|
8
|
-
protected service: TypeGraphQLService;
|
|
9
|
-
protected injector: InjectorService;
|
|
10
|
-
protected configuration: Configuration;
|
|
11
|
-
get settings(): {
|
|
12
|
-
[key: string]: TypeGraphQLSettings;
|
|
13
|
-
} | undefined;
|
|
14
|
-
$onRoutesInit(): Promise<any> | void;
|
|
15
|
-
$afterListen(): Promise<any> | void;
|
|
16
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const RESOLVERS_PROVIDERS = "graphql:resolvers";
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ClassType } from "type-graphql";
|
|
2
|
-
import { AbstractClassOptions, ClassTypeResolver } from "type-graphql/dist/decorators/types";
|
|
3
|
-
export interface ResolverControllerOptions extends AbstractClassOptions {
|
|
4
|
-
id?: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function ResolverController(path?: string): ClassDecorator;
|
|
7
|
-
export declare function ResolverController(options: ResolverControllerOptions): ClassDecorator;
|
|
8
|
-
export declare function ResolverController(typeFunc: ClassTypeResolver, options?: ResolverControllerOptions): ClassDecorator;
|
|
9
|
-
export declare function ResolverController(objectType: ClassType, options?: ResolverControllerOptions): ClassDecorator;
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated Use ResolverController instead
|
|
12
|
-
*/
|
|
13
|
-
export declare function ResolverService(): ClassDecorator;
|
|
14
|
-
export declare function ResolverService(options: AbstractClassOptions): ClassDecorator;
|
|
15
|
-
export declare function ResolverService(typeFunc: ClassTypeResolver, options?: AbstractClassOptions): ClassDecorator;
|
|
16
|
-
export declare function ResolverService(objectType: ClassType, options?: AbstractClassOptions): ClassDecorator;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { DataSource, DataSourceService } from "@tsed/apollo";
|
package/lib/types-esm/index.d.ts
DELETED
|
@@ -1,11 +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 "./services/TypeGraphQLService.js";
|
|
11
|
-
export * from "./TypeGraphQLModule.js";
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { TypeGraphQLSettings } from "./TypeGraphQLSettings.js";
|
|
2
|
-
declare global {
|
|
3
|
-
namespace TsED {
|
|
4
|
-
interface Configuration {
|
|
5
|
-
graphql: {
|
|
6
|
-
[key: string]: TypeGraphQLSettings;
|
|
7
|
-
};
|
|
8
|
-
typegraphql: {
|
|
9
|
-
[key: string]: TypeGraphQLSettings;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export * from "./TypeGraphQLSettings.js";
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ApolloService } from "@tsed/apollo";
|
|
2
|
-
import { Type } from "@tsed/core";
|
|
3
|
-
import { InjectorService } from "@tsed/di";
|
|
4
|
-
import { Logger } from "@tsed/logger";
|
|
5
|
-
import { ApolloServerBase } from "apollo-server-core";
|
|
6
|
-
import { GraphQLSchema } from "graphql";
|
|
7
|
-
import { BuildSchemaOptions } from "type-graphql";
|
|
8
|
-
import { TypeGraphQLSettings } from "../interfaces/interfaces.js";
|
|
9
|
-
export declare class TypeGraphQLService {
|
|
10
|
-
protected injector: InjectorService;
|
|
11
|
-
protected apolloService: ApolloService;
|
|
12
|
-
protected logger: Logger;
|
|
13
|
-
/**
|
|
14
|
-
* Get an instance of ApolloServer from his id
|
|
15
|
-
* @returns ApolloServer
|
|
16
|
-
*/
|
|
17
|
-
get(id?: string): ApolloServerBase | undefined;
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param {string} id
|
|
21
|
-
* @returns {boolean}
|
|
22
|
-
*/
|
|
23
|
-
has(id?: string): boolean;
|
|
24
|
-
createServer(id: string, settings: TypeGraphQLSettings): Promise<ApolloServerBase<any>>;
|
|
25
|
-
/**
|
|
26
|
-
* Create a new type-graphql Schema and bind it with Ts.ED injector.
|
|
27
|
-
* @param buildSchemaOptions
|
|
28
|
-
*/
|
|
29
|
-
createSchema(buildSchemaOptions: BuildSchemaOptions): Promise<GraphQLSchema>;
|
|
30
|
-
/**
|
|
31
|
-
* Get an instance of GraphQL schema from his id
|
|
32
|
-
* @returns GraphQLSchema
|
|
33
|
-
*/
|
|
34
|
-
getSchema(id?: string): GraphQLSchema | undefined;
|
|
35
|
-
protected getResolvers(id: string, resolvers: Type<any>[]): Type<any>[];
|
|
36
|
-
}
|