Closed jahewson closed 8 years ago
Yeah, that's a bit unfortunate. @nnance ran into the same problem a while ago. I don't know of any way around this problem that doesn't involve putting the integrations in separate modules, so that's what we'll do eventually. You'll still need the GraphQL typings, but at least you won't need the typings of servers that you don't use.
And by "eventually" I mean: probably within the next week or two.
Even though installing graphql
, koa
and hapi
I'm still receiving some errors. @jahewson did you solve it?
This is what I'm getting:
node_modules/apollo-server/dist/core/runQuery.d.ts(1,50): error TS2305: Module ''graphql'' has no exported member 'ValidationRule'.
node_modules/apollo-server/dist/integrations/apolloOptions.d.ts(9,37): error TS2305: Module ''graphql'' has no exported member 'ValidationRule'.
typings/modules/koa/index.d.ts(118,10): error TS2305: Module '"http"' has no exported member 'ResponseHeaders'.
typings/modules/koa/index.d.ts(120,10): error TS2305: Module ''~koa/lib/application'' has no exported member 'Application'.
typings/modules/koa/index.d.ts(433,10): error TS2305: Module ''~koa/lib/application'' has no exported member 'Application'.
typings/modules/koa/index.d.ts(778,10): error TS2305: Module ''~koa/lib/application'' has no exported member 'Application'.
typings/modules/koa/index.d.ts(867,36): error TS2304: Cannot find name 'Context'.
typings/modules/koa/index.d.ts(906,40): error TS2304: Cannot find name 'Context'.
Looks like you are missing typings for graphql.. Try npm install --save-dev graphql-typings And make sure that your compiler Has a reference to it. You can see my example repostiory note tsconfig (make sure you are using typescript 2 if you do as i did)
Also typings for koa are missing...
@DxCx I've solved the issue by installing graphql-typings (I was about to write it here) but still receiving the other errors.
@DxCx which koa typings should I use? I've already installed one. See my typings.json
:
{
"globalDependencies": {
"graphql": "github:nitintutlani/typed-graphql",
"hapi": "github:DefinitelyTyped/DefinitelyTyped/hapi/hapi.d.ts#c54072093a1a3a5c28f74dd7b8a57f45d061e536",
"node": "registry:dt/node#6.0.0+20160907103612"
},
"dependencies": {
"body-parser": "registry:npm/body-parser#1.15.2+20160815132839",
"cors": "registry:npm/cors#2.7.0+20160902012746",
"express": "registry:npm/express#4.14.0+20160815112707",
"koa": "registry:npm/koa#2.0.0+20160903085952"
}
}
@DxCx I missed the reference to your repo. Looking into it right now. Thanks! :grinning:
@robertohuertasm I installed typings for graphql, koa and hapi as a workaround. Worked fine.
I've installed them via @types npm package
and it seems to be working. I'm not really sure why using typings
was giving me such headaches. Anyway, thank you very much for your kind help. :grin: :+1:
Great! Happy to hear it :) dont forget to close the ticket ;)
It wasn't opened by me so I left it open. Anyway I think the original issue still remains. Thanks @DxCx for your nice boilerplate!
Yes, the original issue remains.
Wait @jahewson whats the current issue? Since the above looks like typing error and you said its working :)
Original issue is that types for hapi, express, and koa are needed to use this library with TypeScript, regardless of whether or not they are actually "needed", e.g. I don't use koa or express in my project.
Cool, yep i agree it is frustrating.. Ill try to play with it when i have time maybe ill find a soultion ;)
ok @jahewson I've confirmed this to be working
diff --git a/package.json b/package.json
index 1a8e0c1..c359d76 100644
--- a/package.json
+++ b/package.json
@@ -38,9 +38,7 @@
"@types/body-parser": "0.0.31",
"@types/cors": "0.0.31",
"@types/express": "^4.0.31",
- "@types/hapi": "^13.0.33",
"@types/helmet": "0.0.30",
- "@types/koa": "^2.0.31",
"@types/mocha": "^2.2.31",
"@types/morgan": "^1.7.30",
"apollo-server": "0.2.6",
diff --git a/src/main.ts b/src/main.ts
index 534e181..cc9b682 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,6 +1,6 @@
import * as express from "express";
import * as bodyParser from "body-parser";
-import { apolloExpress, graphiqlExpress } from "apollo-server";
+import { apolloExpress, graphiqlExpress } from "apollo-server/dist/integrations/expressApollo";
import { Schema } from "./schema";
import * as cors from "cors";
import * as helmet from "helmet";
so it looks like direct import works, @helfer , @stubailo what are your inputs about this? i think that it's pretty easy to create (At least until better solution will be found) exports to be like:
import { apolloExpress } from "apollo/express"
other solution that is might be worth to explore is namespacing but i haven't try it yet.
@DxCx yeah, I think that's a good idea for the time being. Do you think we should update the docs and readme?
@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.
Hi @helfer i will look into it today which means you will probably have a PR for tomorrow (your) morning
hi @helfer, i was just starting to investigate it and got into consultation that we need to split the whole package, making apollo-server/express / apollo-server/happi / etc work is going to be a pain. then this new issue (#138) from @nnance popped to me.
don't you think it's a better solution? because from what i understand:
taken care along with the monorepo solution. (#138)
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:
You'll get the following errors:
A couple of thoughts:
tsd
to manage type definitions