Skip to content

Commit

Permalink
Use HeaderMap instead of plain Map for headers in expressMiddleware (
Browse files Browse the repository at this point in the history
…#7313)

The `expressMiddleware` handler uses a plain `Map` for the headers that
results in case sensitive lookup on the headers. This makes the header
`Apollo-Query-Plan-Experimental` ineffective when the ApolloServer is
used with `expressMiddleware` handler.

Resolves apollographql/federation#2337
  • Loading branch information
vtipparam committed Jan 18, 2023
1 parent 322b5eb commit ec28b4b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/blue-planets-juggle.md
@@ -0,0 +1,5 @@
---
'@apollo/server': patch
---

Allow case insensitive lookup on headers. Use HeaderMap instead of plain Map for headers in expressMiddleware.
3 changes: 2 additions & 1 deletion packages/server/src/express4/index.ts
Expand Up @@ -7,6 +7,7 @@ import type {
HTTPGraphQLRequest,
} from '../externalTypes/index.js';
import { parse as urlParse } from 'url';
import { HeaderMap } from '../utils/HeaderMap.js';

export interface ExpressContextFunctionArgument {
req: express.Request;
Expand Down Expand Up @@ -56,7 +57,7 @@ export function expressMiddleware<TContext extends BaseContext>(
return;
}

const headers = new Map<string, string>();
const headers = new HeaderMap();
for (const [key, value] of Object.entries(req.headers)) {
if (value !== undefined) {
// Node/Express headers can be an array or a single value. We join
Expand Down

0 comments on commit ec28b4b

Please sign in to comment.