Skip to content

Commit

Permalink
types: Use explicit return type of express.Router on getMiddleware.
Browse files Browse the repository at this point in the history
The TypeScript compiler is inferring the return type of this method
accurately, but emitting `import("express-serve-static-core")` directly into
the `apollo-server-express` type definitions.

Looking at the `package-lock.json` for the Apollo Server repository, I have
a working theory that there are multple `@types/express`'s within this project
and that, when resolving the imports in the delcarations, a copy of
`express-serve-static-core` is not quite in the right resolution path —
potentially due to some package hoisting and module resolution.

To be honest, it's just a theory and I only spent about 3 or 4 minutes
looking at this, but I hope that this will address #3222 (intentionally not
using the keyword "Fixes" here because we'll wait for validation!)
  • Loading branch information
abernix committed Aug 29, 2019
1 parent c9aa70b commit 2d159b9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The version headers in this history reflect the versions of Apollo Server itself

> The changes noted within this `vNEXT` section have not been released yet. New PRs and commits which introduce changes should include an entry in this `vNEXT` section as part of their development. When a release is being prepared, a new header will be (manually) created below and the the appropriate changes within that release will be moved into the new section.
- Nothing yet! Stay tuned!
- `apollo-server-express`: Use explicit return type for new `getMiddleware` method, in an effort to resolve [Issue #3222](https://github.com/apollographql/apollo-server/issues/3222) [PR #TODO](https://github.com/apollographql/apollo-server/pull/TODO)

### v2.9.1

Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-express/src/ApolloServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class ApolloServer extends ApolloServerBase {
bodyParserConfig,
disableHealthCheck,
onHealthCheck,
}: GetMiddlewareOptions = {}) {
}: GetMiddlewareOptions = {}): express.Router {
if (!path) path = '/graphql';

const router = express.Router();
Expand Down

0 comments on commit 2d159b9

Please sign in to comment.