@tsed/apollo 7.22.2 → 7.23.1

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.
@@ -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;
@@ -2,5 +2,7 @@
2
2
  * @file Automatically generated by barrelsby.
3
3
  */
4
4
  export * from "./ApolloModule";
5
+ export * from "./constants/constants";
6
+ export * from "./decorators/dataSource";
5
7
  export * from "./interfaces/ApolloSettings";
6
8
  export * from "./services/ApolloService";
@@ -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
- createServer(id: string, settings: ApolloSettings): Promise<any>;
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.22.2",
3
+ "version": "7.23.1",
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.22.2",
29
- "@tsed/core": "7.22.2",
30
- "@tsed/di": "7.22.2",
31
- "@tsed/eslint": "7.22.2",
28
+ "@tsed/common": "7.23.1",
29
+ "@tsed/core": "7.23.1",
30
+ "@tsed/di": "7.23.1",
31
+ "@tsed/eslint": "7.23.1",
32
32
  "@tsed/logger": ">=6.2.2",
33
- "@tsed/typescript": "7.22.2",
33
+ "@tsed/typescript": "7.23.1",
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.22.2",
46
- "@tsed/core": "^7.22.2",
47
- "@tsed/di": "^7.22.2",
45
+ "@tsed/common": "^7.23.1",
46
+ "@tsed/core": "^7.23.1",
47
+ "@tsed/di": "^7.23.1",
48
48
  "@tsed/logger": ">=6.2.2",
49
49
  "apollo-datasource": ">=3.0.0",
50
50
  "apollo-datasource-rest": ">=3.0.0",