@tsed/typegraphql 7.22.2 → 7.23.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.
- package/jest.config.js +4 -4
- package/lib/cjs/constants/constants.js +2 -3
- package/lib/cjs/constants/constants.js.map +1 -1
- package/lib/cjs/decorators/{resolverService.js → resolver.js} +8 -4
- package/lib/cjs/decorators/resolver.js.map +1 -0
- package/lib/cjs/exports.js +7 -0
- package/lib/cjs/exports.js.map +1 -0
- package/lib/cjs/index.js +2 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/services/TypeGraphQLService.js +35 -66
- package/lib/cjs/services/TypeGraphQLService.js.map +1 -1
- package/lib/esm/constants/constants.js +1 -2
- package/lib/esm/constants/constants.js.map +1 -1
- package/lib/esm/decorators/{resolverService.js → resolver.js} +7 -4
- package/lib/esm/decorators/resolver.js.map +1 -0
- package/lib/esm/exports.js +2 -0
- package/lib/esm/exports.js.map +1 -0
- package/lib/esm/index.js +2 -2
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/services/TypeGraphQLService.js +36 -67
- package/lib/esm/services/TypeGraphQLService.js.map +1 -1
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/constants/constants.d.ts +1 -2
- package/lib/types/decorators/{resolverService.d.ts → resolver.d.ts} +7 -0
- package/lib/types/exports.d.ts +1 -0
- package/lib/types/index.d.ts +2 -2
- package/lib/types/services/TypeGraphQLService.d.ts +2 -11
- package/package.json +6 -6
- package/readme.md +2 -2
- package/lib/cjs/decorators/dataSourceService.js +0 -40
- package/lib/cjs/decorators/dataSourceService.js.map +0 -1
- package/lib/cjs/decorators/resolverService.js.map +0 -1
- package/lib/esm/decorators/dataSourceService.js +0 -36
- package/lib/esm/decorators/dataSourceService.js.map +0 -1
- package/lib/esm/decorators/resolverService.js.map +0 -1
- package/lib/types/decorators/dataSourceService.d.ts +0 -28
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const PROVIDER_TYPE_RESOLVER_SERVICE = "graphQLResolverService";
|
|
1
|
+
export declare const RESOLVERS_PROVIDERS = "graphql:resolvers";
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { ClassType } from "type-graphql";
|
|
2
2
|
import { AbstractClassOptions, ClassTypeResolver } from "type-graphql/dist/decorators/types";
|
|
3
|
+
export declare function ResolverController(): ClassDecorator;
|
|
4
|
+
export declare function ResolverController(options: AbstractClassOptions): ClassDecorator;
|
|
5
|
+
export declare function ResolverController(typeFunc: ClassTypeResolver, options?: AbstractClassOptions): ClassDecorator;
|
|
6
|
+
export declare function ResolverController(objectType: ClassType, options?: AbstractClassOptions): ClassDecorator;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use ResolverController instead
|
|
9
|
+
*/
|
|
3
10
|
export declare function ResolverService(): ClassDecorator;
|
|
4
11
|
export declare function ResolverService(options: AbstractClassOptions): ClassDecorator;
|
|
5
12
|
export declare function ResolverService(typeFunc: ClassTypeResolver, options?: AbstractClassOptions): ClassDecorator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataSource, DataSourceService } from "@tsed/apollo";
|
package/lib/types/index.d.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* @file Automatically generated by barrelsby.
|
|
3
3
|
*/
|
|
4
4
|
export * from "./TypeGraphQLModule";
|
|
5
|
+
export * from "./exports";
|
|
5
6
|
export * from "./constants/constants";
|
|
6
|
-
export * from "./decorators/
|
|
7
|
-
export * from "./decorators/resolverService";
|
|
7
|
+
export * from "./decorators/resolver";
|
|
8
8
|
export * from "./interfaces/TypeGraphQLSettings";
|
|
9
9
|
export * from "./interfaces/interfaces";
|
|
10
10
|
export * from "./services/TypeGraphQLService";
|
|
@@ -2,10 +2,9 @@ import { ApolloService } from "@tsed/apollo";
|
|
|
2
2
|
import { Type } from "@tsed/core";
|
|
3
3
|
import { InjectorService } from "@tsed/di";
|
|
4
4
|
import { Logger } from "@tsed/logger";
|
|
5
|
-
import {
|
|
5
|
+
import { ApolloServerBase } from "apollo-server-core";
|
|
6
6
|
import { GraphQLSchema } from "graphql";
|
|
7
7
|
import { BuildSchemaOptions } from "type-graphql";
|
|
8
|
-
import { ApolloServerBase } from "apollo-server-core";
|
|
9
8
|
import { TypeGraphQLSettings } from "../interfaces/interfaces";
|
|
10
9
|
export declare class TypeGraphQLService {
|
|
11
10
|
protected injector: InjectorService;
|
|
@@ -26,7 +25,7 @@ export declare class TypeGraphQLService {
|
|
|
26
25
|
*
|
|
27
26
|
* @returns {Promise<ApolloServer>}
|
|
28
27
|
*/
|
|
29
|
-
createServer(id: string, settings: TypeGraphQLSettings): Promise<any
|
|
28
|
+
createServer(id: string, settings: TypeGraphQLSettings): Promise<ApolloServerBase<any>>;
|
|
30
29
|
/**
|
|
31
30
|
* Create a new type-graphql Schema and bind it with Ts.ED injector.
|
|
32
31
|
* @param buildSchemaOptions
|
|
@@ -42,12 +41,4 @@ export declare class TypeGraphQLService {
|
|
|
42
41
|
* @returns {Provider<any>[]}
|
|
43
42
|
*/
|
|
44
43
|
protected getResolvers(): Type<any>[];
|
|
45
|
-
protected getDataSources(): Record<string, DataSource>;
|
|
46
|
-
/**
|
|
47
|
-
* create a new dataSources function to use with apollo server config
|
|
48
|
-
* @param dataSources
|
|
49
|
-
* @param serverConfigSources
|
|
50
|
-
*/
|
|
51
|
-
protected createDataSources(dataSources: Function | undefined, serverConfigSources: Function | undefined): () => any;
|
|
52
|
-
protected configureTypeGraphQLDI(): void;
|
|
53
44
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/typegraphql",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.23.0",
|
|
4
4
|
"description": "TypeGraphQL package for Ts.ED framework, based on Apollo-server-core and Type-graphql",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"lint:fix": "eslint '**/*.{ts,js}' --fix"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@tsed/apollo": "7.
|
|
27
|
+
"@tsed/apollo": "7.23.0",
|
|
28
28
|
"tslib": "2.5.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@tsed/common": "7.
|
|
32
|
-
"@tsed/core": "7.
|
|
33
|
-
"@tsed/eslint": "7.
|
|
34
|
-
"@tsed/typescript": "7.
|
|
31
|
+
"@tsed/common": "7.23.0",
|
|
32
|
+
"@tsed/core": "7.23.0",
|
|
33
|
+
"@tsed/eslint": "7.23.0",
|
|
34
|
+
"@tsed/typescript": "7.23.0",
|
|
35
35
|
"@types/graphql": "^14.5.0",
|
|
36
36
|
"class-validator": "~0.14.0",
|
|
37
37
|
"eslint": "^8.12.0",
|
package/readme.md
CHANGED
|
@@ -147,12 +147,12 @@ After that we want to create typical crud queries and mutation. To do that we cr
|
|
|
147
147
|
|
|
148
148
|
```typescript
|
|
149
149
|
import {Resolver, Query, Arg, Args, Mutation, Authorized, Ctx} from "type-graphql";
|
|
150
|
-
import {
|
|
150
|
+
import {ResolverController} from "@tsed/typegraphql";
|
|
151
151
|
import {Recipe} from "../types/Recipe";
|
|
152
152
|
import {RecipeService} from "../services/RecipeService";
|
|
153
153
|
import {RecipeNotFoundError} from "../errors/RecipeNotFoundError";
|
|
154
154
|
|
|
155
|
-
@
|
|
155
|
+
@ResolverController(Recipe)
|
|
156
156
|
export class RecipeResolver {
|
|
157
157
|
constructor(private recipeService: RecipeService) {}
|
|
158
158
|
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DataSourceService = void 0;
|
|
4
|
-
const di_1 = require("@tsed/di");
|
|
5
|
-
const constants_1 = require("../constants/constants");
|
|
6
|
-
/**
|
|
7
|
-
* Create a new DataSource binded with Tsed DI.
|
|
8
|
-
*
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import { DataSourceService } from "@tsed/graphql";
|
|
11
|
-
* import { RESTDataSource } from 'apollo-datasource-rest';
|
|
12
|
-
*
|
|
13
|
-
* @DataSourceService()
|
|
14
|
-
* export class MyDataSource extends RESTDataSource {
|
|
15
|
-
* constructor() {
|
|
16
|
-
* super();
|
|
17
|
-
* this.baseURL = 'https://awesome-api.example.com';
|
|
18
|
-
* }
|
|
19
|
-
*
|
|
20
|
-
* willSendRequest(request) {
|
|
21
|
-
* request.headers.set('Authorization', this.context.token);
|
|
22
|
-
* }
|
|
23
|
-
*
|
|
24
|
-
* getMyData(id: string) {
|
|
25
|
-
* return this.get(`/v1/my_rest_data/${id}`);
|
|
26
|
-
* }
|
|
27
|
-
* }
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @decorator
|
|
31
|
-
* @graphql
|
|
32
|
-
*/
|
|
33
|
-
function DataSourceService() {
|
|
34
|
-
return (0, di_1.Injectable)({
|
|
35
|
-
type: constants_1.PROVIDER_TYPE_DATASOURCE_SERVICE,
|
|
36
|
-
scope: di_1.ProviderScope.INSTANCE
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
exports.DataSourceService = DataSourceService;
|
|
40
|
-
//# sourceMappingURL=dataSourceService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dataSourceService.js","sourceRoot":"","sources":["../../../src/decorators/dataSourceService.ts"],"names":[],"mappings":";;;AAAA,iCAAmD;AACnD,sDAAwE;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,iBAAiB;IAC/B,OAAO,IAAA,eAAU,EAAC;QAChB,IAAI,EAAE,4CAAgC;QACtC,KAAK,EAAE,kBAAa,CAAC,QAAQ;KAC9B,CAAC,CAAC;AACL,CAAC;AALD,8CAKC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolverService.js","sourceRoot":"","sources":["../../../src/decorators/resolverService.ts"],"names":[],"mappings":";;;AAAA,qCAAyC;AACzC,iCAAoC;AACpC,+CAAiD;AAEjD,sDAAsE;AAMtE,SAAgB,eAAe,CAAC,GAAG,IAAW;IAC5C,OAAO,IAAA,oBAAa,EACjB,uBAAgB,CAAC,GAAG,IAAI,CAAC,EAC1B,IAAA,eAAU,EAAC;QACT,IAAI,EAAE,0CAA8B;KACrC,CAAC,CACH,CAAC;AACJ,CAAC;AAPD,0CAOC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Injectable, ProviderScope } from "@tsed/di";
|
|
2
|
-
import { PROVIDER_TYPE_DATASOURCE_SERVICE } from "../constants/constants.js";
|
|
3
|
-
/**
|
|
4
|
-
* Create a new DataSource binded with Tsed DI.
|
|
5
|
-
*
|
|
6
|
-
* ```typescript
|
|
7
|
-
* import { DataSourceService } from "@tsed/graphql";
|
|
8
|
-
* import { RESTDataSource } from 'apollo-datasource-rest';
|
|
9
|
-
*
|
|
10
|
-
* @DataSourceService()
|
|
11
|
-
* export class MyDataSource extends RESTDataSource {
|
|
12
|
-
* constructor() {
|
|
13
|
-
* super();
|
|
14
|
-
* this.baseURL = 'https://awesome-api.example.com';
|
|
15
|
-
* }
|
|
16
|
-
*
|
|
17
|
-
* willSendRequest(request) {
|
|
18
|
-
* request.headers.set('Authorization', this.context.token);
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* getMyData(id: string) {
|
|
22
|
-
* return this.get(`/v1/my_rest_data/${id}`);
|
|
23
|
-
* }
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @decorator
|
|
28
|
-
* @graphql
|
|
29
|
-
*/
|
|
30
|
-
export function DataSourceService() {
|
|
31
|
-
return Injectable({
|
|
32
|
-
type: PROVIDER_TYPE_DATASOURCE_SERVICE,
|
|
33
|
-
scope: ProviderScope.INSTANCE
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=dataSourceService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dataSourceService.js","sourceRoot":"","sources":["../../../src/decorators/dataSourceService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,UAAU,CAAC;AACnD,OAAO,EAAC,gCAAgC,EAAC,MAAM,wBAAwB,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,UAAU,CAAC;QAChB,IAAI,EAAE,gCAAgC;QACtC,KAAK,EAAE,aAAa,CAAC,QAAQ;KAC9B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolverService.js","sourceRoot":"","sources":["../../../src/decorators/resolverService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAY,QAAQ,EAAC,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAC,8BAA8B,EAAC,MAAM,wBAAwB,CAAC;AAMtE,MAAM,UAAU,eAAe,CAAC,GAAG,IAAW;IAC5C,OAAO,aAAa,CACjB,QAAgB,CAAC,GAAG,IAAI,CAAC,EAC1B,UAAU,CAAC;QACT,IAAI,EAAE,8BAA8B;KACrC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create a new DataSource binded with Tsed DI.
|
|
3
|
-
*
|
|
4
|
-
* ```typescript
|
|
5
|
-
* import { DataSourceService } from "@tsed/graphql";
|
|
6
|
-
* import { RESTDataSource } from 'apollo-datasource-rest';
|
|
7
|
-
*
|
|
8
|
-
* @DataSourceService()
|
|
9
|
-
* export class MyDataSource extends RESTDataSource {
|
|
10
|
-
* constructor() {
|
|
11
|
-
* super();
|
|
12
|
-
* this.baseURL = 'https://awesome-api.example.com';
|
|
13
|
-
* }
|
|
14
|
-
*
|
|
15
|
-
* willSendRequest(request) {
|
|
16
|
-
* request.headers.set('Authorization', this.context.token);
|
|
17
|
-
* }
|
|
18
|
-
*
|
|
19
|
-
* getMyData(id: string) {
|
|
20
|
-
* return this.get(`/v1/my_rest_data/${id}`);
|
|
21
|
-
* }
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @decorator
|
|
26
|
-
* @graphql
|
|
27
|
-
*/
|
|
28
|
-
export declare function DataSourceService(): ClassDecorator;
|