@tsed/apollo 8.20.1 → 8.22.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.
@@ -43,7 +43,19 @@ export class ApolloService {
43
43
  const contextHandler = this.createContextHandler(server, settings);
44
44
  switch (this.platformName) {
45
45
  case "express":
46
- const { expressMiddleware } = await import("@apollo/server/express4");
46
+ // use newer graphql express middleware
47
+ const expressVersion = await import("express/package.json").then((pkg) => pkg.default.version);
48
+ const majorVersion = parseInt(expressVersion.split(".")[0], 10);
49
+ let expressMiddleware;
50
+ if (majorVersion >= 5) {
51
+ ({ expressMiddleware } = await import("@as-integrations/express5"));
52
+ }
53
+ else if (majorVersion === 4) {
54
+ ({ expressMiddleware } = await import("@as-integrations/express4"));
55
+ }
56
+ else {
57
+ throw new Error(`Express version ${expressVersion} is not supported. Please use Express 4 or 5.`);
58
+ }
47
59
  this.app.use(path, expressMiddleware(server, {
48
60
  ...middlewareOptions,
49
61
  context: contextHandler
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tsed/apollo",
3
3
  "description": "Apollo package for Ts.ED framework",
4
4
  "type": "module",
5
- "version": "8.20.1",
5
+ "version": "8.22.0",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
@@ -27,29 +27,50 @@
27
27
  },
28
28
  "devDependencies": {
29
29
  "@apollo/datasource-rest": "6.4.1",
30
- "@apollo/server": "^4.11.0",
30
+ "@apollo/server": "^5.2.0",
31
+ "@as-integrations/express4": "1.1.2",
32
+ "@as-integrations/express5": "1.1.2",
33
+ "@as-integrations/fastify": "3.1.0",
31
34
  "@as-integrations/koa": "1.1.1",
32
- "@tsed/barrels": "8.20.1",
33
- "@tsed/core": "8.20.1",
34
- "@tsed/di": "8.20.1",
35
+ "@tsed/barrels": "8.22.0",
36
+ "@tsed/core": "8.22.0",
37
+ "@tsed/di": "8.22.0",
35
38
  "@tsed/logger": "^8.0.0",
36
- "@tsed/platform-http": "8.20.1",
37
- "@tsed/typescript": "8.20.1",
39
+ "@tsed/platform-http": "8.22.0",
40
+ "@tsed/typescript": "8.22.0",
38
41
  "apollo-datasource-http": "0.21.0",
39
42
  "apollo-server-testing": "2.26.2",
40
43
  "eslint": "9.12.0",
41
- "graphql": "16.9.0",
44
+ "graphql": "16.12.0",
42
45
  "typescript": "5.9.3",
43
46
  "vitest": "3.2.4"
44
47
  },
45
48
  "peerDependencies": {
46
- "@apollo/server": ">=4.10.4",
49
+ "@apollo/server": ">=4.12.0",
50
+ "@as-integrations/express4": ">=1.1.2",
51
+ "@as-integrations/express5": ">=1.1.2",
52
+ "@as-integrations/fastify": ">=3.1.0",
53
+ "@as-integrations/koa": ">=1.1.1",
47
54
  "@tsed/core": ">=8.0.0",
48
55
  "@tsed/di": ">=8.0.0",
49
56
  "@tsed/logger": ">=8.0.0",
50
57
  "@tsed/platform-http": ">=8.0.0",
51
58
  "graphql": ">16.0.0"
52
59
  },
60
+ "peerDependenciesMeta": {
61
+ "@as-integrations/express4": {
62
+ "optional": true
63
+ },
64
+ "@as-integrations/express5": {
65
+ "optional": true
66
+ },
67
+ "@as-integrations/fastify": {
68
+ "optional": true
69
+ },
70
+ "@as-integrations/koa": {
71
+ "optional": true
72
+ }
73
+ },
53
74
  "repository": "https://github.com/tsedio/tsed",
54
75
  "bugs": {
55
76
  "url": "https://github.com/tsedio/tsed/issues"
package/readme.md CHANGED
@@ -45,10 +45,37 @@ If you're looking for integration with TypeGraphQL see the [`@tsed/typegraphql`]
45
45
  To begin, install the Apollo module for TS.ED:
46
46
 
47
47
  ```bash
48
- npm install --save @tsed/apollo graphql@15 @apollo/server apollo/datasource-rest
48
+ npm install --save @tsed/apollo graphql@16 @apollo/server apollo/datasource-rest
49
49
  npm install --save-dev apollo-server-testing
50
+
51
+ ```
52
+
53
+ ### Express Integration
54
+
55
+ If you are using express you need to install its respective integration:
56
+
57
+ - Express 4 - [@as-integrations/express4](https://www.npmjs.com/package/@as-integrations/express4)
58
+
59
+ ``` bash
60
+ npm install --save @as-integrations/express4
50
61
  ```
51
62
 
63
+ - Express 5 - [@as-integrations/express5](https://www.npmjs.com/package/@as-integrations/express5)
64
+
65
+ ``` bash
66
+ npm install --save @as-integrations/express5
67
+ ```
68
+
69
+ ### Koa Integration
70
+
71
+ ```bash
72
+ npm install --save @as-integrations/koa
73
+ ```
74
+
75
+ ### Fastify Integration
76
+
77
+ `Coming Soon`
78
+
52
79
  Now, we can configure the Ts.ED server by importing `@tsed/apollo` in your Server:
53
80
 
54
81
  ```typescript