Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add arbitrary property to
HeaderMap
for type differentiation (#7314)
Related: #7313 This shouldn't have been allowed by the typings in the first place. Previously, a `Map` was compatible with `HeaderMap` according to TypeScript, so the error wasn't a typing error (when we wanted it to be). Adding an arbitrary class property to the `HeaderMap` class gives us the typing error we'd expect when a `Map` is used in lieu of a `HeaderMap`.
- Loading branch information
1 parent
f329139
commit f246ddb
Showing
4 changed files
with
24 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
'@apollo/server': patch | ||
--- | ||
|
||
Add an `__identity` property to `HeaderMap` class to disallow standard `Map`s (in TypeScript). | ||
|
||
This ensures that typechecking occurs on fields which are declared to accept a | ||
`HeaderMap` (notably, the `httpGraphQLRequest.headers` option to | ||
`ApolloServer.executeHTTPGraphQLRequest` and the `http.headers` option to | ||
`ApolloServer.executeOperation`). This might be a breaking change for | ||
integration authors, but should be easily fixed by switching from `new | ||
Map<string, string>()` to `new HeaderMap()`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters