Closed anodynos closed 5 years ago
I facing the same issue.
Event though my tsconfig.json ignores node_modules:
"exclude": [ "node_modules" ]
the error occurs
I realized how make it work:
import voyagerMiddleware = require('graphql-voyager/middleware/express'); app.use('/voyager', voyagerMiddleware.default({ endpointUrl: '/graphql' }));
this way worked better:
import voyagerMiddleware from 'graphql-voyager/middleware/express'; app.use('/voyager', voyagerMiddleware({ endpointUrl: '/graphql' }));
@anodynos @daniloferreira Just published 1.0.0-rc.26
📦 with a fix included. Can you please try.
this way worked better: import voyagerMiddleware from 'graphql-voyager/middleware/express'; app.use('/voyager', voyagerMiddleware({ endpointUrl: '/graphql' }));
@daniloferreira It's workaround not a full fix since express middlaware still depends on @types/express
. So I just removed all externall types from middlewares to completely solve this problem.
@IvanGoncharov I get TypeError: voyagerMiddleware is not a function
with the following imports on 1.0.0-rc.26
:
import { express as voyagerMiddleware } from 'graphql-voyager/middleware'; // => undefined
//or
import voyagerMiddleware from 'graphql-voyager/middleware/express'; // => { }
@Apollinaire Strange, it works for me when I'm doing:
const { express: voyagerMiddleware } = require('graphql-voyager/middleware');
Can you please test the same code in your setup.
I see you are using ES6 modules, what environment do you using babel
, typescript
, esm
?
I'm using Meteor to build, with the ecmascript
package, which uses Babel under the hood. To be more precise, i'm trying to include this to vulcan.js : https://github.com/vulcanjs/vulcan
Any import on server side returns undefined. On the client it works, but I need the middleware to run serverside only, because that's where I create my express app.
@Apollinaire I'm not familiar with meteor so can you please create GitHub repo with the minimal setup to reproduce this issue?
After further search, it seems related to how I build my project. Something in my config must be wrong because I am able to import and run the middleware in other Vulcan/Meteor projects. I'll update this when I've found the issue, it might be useful for future people Thanks for your time @IvanGoncharov
@Apollinaire I'm closing this issue since the original issue was resolved. But please post your findings here it will help if other Meteor users will have the same problem.
@IvanGoncharov thanks, it worked great!
import voyagerMiddleware from 'graphql-voyager/middleware/express';
app.use('/voyager', voyagerMiddleware({ endpointUrl: '/graphql' }));
@IvanGoncharov it was just some bad config from me, other should not have the same problem.
@Apollinaire I'm running into the same issue on my own Vulcan project, how did you fix it?
@SachaG IIRC the problem was that I was doing npm i --save-dev graphql-voyager
because I was thinking that I only had to use it on dev environment. But Meteor did not like this, so I just did npm i graphql-voyager
and it worked !
Haha exact same issue for me! Thanks!
Guess who got the same issue
Haha exact same issue for me! Thanks!
Guess who got the same issue
We're one damn fine core team for Vulcan.js
When importing as mentioned in docs for an express project:
I get
from
typescript@2.9.2