Skip to content

Commit 0446a10

Browse files
committed
Update for Express v5
Specifically, `express.json()` in Express v5 now uses `body-parser@2`, which initializes `req.body` to `undefined` instead of `{}`. People can also use either major version of `body-parser` with either version of Express, so we should support both versions here. Fortunately, we can maintain this helpful advice for people with misconfigured apps by looking to see if the field exists at all.
1 parent cb0c12f commit 0446a10

6 files changed

Lines changed: 979 additions & 685 deletions

File tree

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://unpkg.com/@changesets/config@1.6.3/schema.json",
33
"changelog": [
44
"@changesets/changelog-github",
5-
{ "repo": "apollo-server-integrations/apollo-server-integration-express4" }
5+
{ "repo": "apollo-server-integrations/apollo-server-integration-express5" }
66
],
77
"commit": false,
88
"access": "public",

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
1-
# @as-integrations/express4
1+
# @as-integrations/express5
22

3+
## 0.0.0
4+
5+
Initial release.
6+
7+
Based on `@apollo/server/express4`, updated for Express v5.
8+
9+
The check to see if you forgot to install the JSON body parser now works with
10+
`body-parser` v2 (and thus `express.json()` in Express v5) as well as with the
11+
older version.

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
# Apollo Server Integration for Express v4
1+
# Apollo Server Integration for Express v5
22

33
## **Introduction**
44

5-
This package integrates Apollo Server v4 with version 4 of the Express web framework, by exporting a middleware that executes GraphQL operations.
5+
This package integrates Apollo Server v4 with version 5 of the Express web framework, by exporting a middleware that executes GraphQL operations.
66

7-
It is identical to the middleware exported at `@apollo/server/express4` from the core `@apollo/server` v4 package. It is being provided separately so that we can also provide an integration with Express v5 (`@as-integrations/express5`); future major versions of Apollo Server will not have built-in support for Express.
7+
It is identical to the middleware exported at `@apollo/server/express5` from the core `@apollo/server` v4 package, updated to support Express v5 instead of Express v4.
88

99
## **Requirements**
1010

1111
- **[Node.js v20](https://nodejs.org/)** or later
12-
- **[Express v4](https://expressjs.com/)**; this package does *not* support Express v5
12+
- **[Express v5](https://expressjs.com/)**; see `@as-integrations/express4` for Express v4 support
1313
- **[Apollo Server v4](https://www.apollographql.com/docs/apollo-server/)**
1414

1515
## **Installation**
1616

1717
```bash
18-
npm install @apollo/server graphql express@4 @as-integrations/express4 cors
18+
npm install @apollo/server graphql express@5 @as-integrations/express5 cors
1919
```
2020

2121
## **Usage**
@@ -24,7 +24,7 @@ Set up [Express](https://expressjs.com/) & [Apollo Server](https://www.apollogra
2424

2525
```typescript
2626
import { ApolloServer } from '@apollo/server';
27-
import { expressMiddleware } from '@as-integrations/express4';
27+
import { expressMiddleware } from '@as-integrations/express5';
2828
import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer';
2929
import express from 'express';
3030
import http from 'http';

0 commit comments

Comments
 (0)