apollo-server: Missing modules when used from TypeScript

Hi, I’m trying to use apollo-server with TypeScript, however I’m unable to get the compilation working due to missing module definitions.

I’ve published my ts port of apollo-starter-kit. If you clone that and run:

npm install
npm run compile

You’ll get the following errors:

node_modules/apollo-server/dist/core/runQuery.d.ts(1,72): error TS2307: Cannot find module 'graphql'.
node_modules/apollo-server/dist/integrations/apolloOptions.d.ts(1,26): error TS2307: Cannot find module 'graphql'.
node_modules/apollo-server/dist/integrations/hapiApollo.d.ts(1,23): error TS2307: Cannot find module 'hapi'.
node_modules/apollo-server/dist/integrations/koaApollo.d.ts(1,22): error TS2307: Cannot find module 'koa'.
node_modules/apollo-server/dist/modules/operationStore.d.ts(1,41): error TS2307: Cannot find module 'graphql'.

A couple of thoughts:

  • I’m using tsd to manage type definitions
  • I can see that installing these typings into my project could be a workaround, but I don’t really want to pollute my typings directory with koa and hapi typings that I never need.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 2
  • Comments: 23 (14 by maintainers)

Commits related to this issue

Most upvoted comments

Hi @helfer i will look into it today which means you will probably have a PR for tomorrow (your) morning

@helfer indeed, Leaving it as is will just result in people being affriad of using the server 😕

But i do think it should be more intuitive then using dist/integrations As i said before maybe apollo-server/express apollo-server/koa etc…

yes, the following style would be great:

import apolloExpress from 'apollo-server/express';

If that’s all we need to get rid of the typings errors, then I’d say we should do it for the 0.3 release (which we wanted to do today or tomorrow). @jahewson or @DxCx would one of you be willing to make a quick PR for that? I think all that’s needed would be to make four folders (express, hapi, koa, connect) and put an index file with the proper exports in it.

And by “eventually” I mean: probably within the next week or two.