@tsed/apollo 7.22.1 → 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 +3 -3
- package/lib/cjs/constants/constants.js +5 -0
- package/lib/cjs/constants/constants.js.map +1 -0
- package/lib/cjs/decorators/dataSource.js +69 -0
- package/lib/cjs/decorators/dataSource.js.map +1 -0
- package/lib/cjs/index.js +2 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/services/ApolloService.js +63 -33
- package/lib/cjs/services/ApolloService.js.map +1 -1
- package/lib/esm/constants/constants.js +2 -0
- package/lib/esm/constants/constants.js.map +1 -0
- package/lib/esm/decorators/dataSource.js +65 -0
- package/lib/esm/decorators/dataSource.js.map +1 -0
- package/lib/esm/index.js +2 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/services/ApolloService.js +64 -34
- package/lib/esm/services/ApolloService.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 -0
- package/lib/types/decorators/dataSource.d.ts +56 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/services/ApolloService.d.ts +9 -1
- package/package.json +9 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DATASOURCES_PROVIDERS = "graphql:datasources";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a new injectable DataSource.
|
|
3
|
+
*
|
|
4
|
+
* ```typescript
|
|
5
|
+
* import { DataSourceService } from "@tsed/graphql";
|
|
6
|
+
* import { RESTDataSource } from 'apollo-datasource-rest';
|
|
7
|
+
*
|
|
8
|
+
* @DataSource()
|
|
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 DataSource(name?: string): ClassDecorator;
|
|
29
|
+
/**
|
|
30
|
+
* Create a new injectable DataSource.
|
|
31
|
+
*
|
|
32
|
+
* ```typescript
|
|
33
|
+
* import { DataSourceService } from "@tsed/graphql";
|
|
34
|
+
* import { RESTDataSource } from 'apollo-datasource-rest';
|
|
35
|
+
*
|
|
36
|
+
* @DataSource()
|
|
37
|
+
* export class MyDataSource extends RESTDataSource {
|
|
38
|
+
* constructor() {
|
|
39
|
+
* super();
|
|
40
|
+
* this.baseURL = 'https://awesome-api.example.com';
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
* willSendRequest(request) {
|
|
44
|
+
* request.headers.set('Authorization', this.context.token);
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* getMyData(id: string) {
|
|
48
|
+
* return this.get(`/v1/my_rest_data/${id}`);
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @decorator
|
|
54
|
+
* @graphql
|
|
55
|
+
*/
|
|
56
|
+
export declare const DataSourceService: typeof DataSource;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { GraphQLSchema } from "graphql";
|
|
|
5
5
|
import type { ApolloServer, ApolloSettings } from "../interfaces/ApolloSettings";
|
|
6
6
|
import { ApolloCustomServerCB } from "../interfaces/ApolloSettings";
|
|
7
7
|
export declare class ApolloService {
|
|
8
|
+
protected dataSources: any[];
|
|
8
9
|
platformName: string;
|
|
9
10
|
protected logger: Logger;
|
|
10
11
|
/**
|
|
@@ -19,7 +20,8 @@ export declare class ApolloService {
|
|
|
19
20
|
private app;
|
|
20
21
|
private httpServer;
|
|
21
22
|
private httpsServer;
|
|
22
|
-
|
|
23
|
+
constructor(dataSources: any[]);
|
|
24
|
+
createServer(id: string, settings: ApolloSettings): Promise<ApolloServer>;
|
|
23
25
|
/**
|
|
24
26
|
* Get an instance of ApolloServer from his id
|
|
25
27
|
* @returns ApolloServer
|
|
@@ -37,5 +39,11 @@ export declare class ApolloService {
|
|
|
37
39
|
*/
|
|
38
40
|
has(id?: string): boolean;
|
|
39
41
|
protected createInstance(options: Config, server?: ApolloCustomServerCB): Promise<ApolloServer | undefined>;
|
|
42
|
+
/**
|
|
43
|
+
* create a new dataSources function to use with apollo server config
|
|
44
|
+
* @param dataSources
|
|
45
|
+
* @param serverConfigSources
|
|
46
|
+
*/
|
|
47
|
+
protected createDataSources(dataSources: Function | undefined): () => any;
|
|
40
48
|
private getPlugins;
|
|
41
49
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/apollo",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.23.0",
|
|
4
4
|
"description": "Apollo package for Ts.ED framework",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
},
|
|
26
26
|
"private": false,
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@tsed/common": "7.
|
|
29
|
-
"@tsed/core": "7.
|
|
30
|
-
"@tsed/di": "7.
|
|
31
|
-
"@tsed/eslint": "7.
|
|
28
|
+
"@tsed/common": "7.23.0",
|
|
29
|
+
"@tsed/core": "7.23.0",
|
|
30
|
+
"@tsed/di": "7.23.0",
|
|
31
|
+
"@tsed/eslint": "7.23.0",
|
|
32
32
|
"@tsed/logger": ">=6.2.2",
|
|
33
|
-
"@tsed/typescript": "7.
|
|
33
|
+
"@tsed/typescript": "7.23.0",
|
|
34
34
|
"@types/graphql": "14.5.0",
|
|
35
35
|
"apollo-datasource": "^3.2.0",
|
|
36
36
|
"apollo-datasource-rest": "^3.3.0",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"graphql": "15.7.2"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@tsed/common": "^7.
|
|
46
|
-
"@tsed/core": "^7.
|
|
47
|
-
"@tsed/di": "^7.
|
|
45
|
+
"@tsed/common": "^7.23.0",
|
|
46
|
+
"@tsed/core": "^7.23.0",
|
|
47
|
+
"@tsed/di": "^7.23.0",
|
|
48
48
|
"@tsed/logger": ">=6.2.2",
|
|
49
49
|
"apollo-datasource": ">=3.0.0",
|
|
50
50
|
"apollo-datasource-rest": ">=3.0.0",
|