Unable to require the module using import in Typescript after this change: #92 . It compiles, but seems like the module doesn't have any default export.
Code:
import graphqlHTTP from 'express-graphql';
import schema from './schema';
const graphqlMiddleware:any = graphqlHTTP({
graphiql: true,
pretty: true,
schema: schema,
});
runtime error:
const graphqlMiddleware = express_graphql_1.default({
^
TypeError: express_graphql_1.default is not a function
tsconfig:
"compilerOptions": {
"target": "es2015",
"module": "commonjs",
"moduleResolution": "node"
}
Or maybe this issue belongs here: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/express-graphql
It's a problem with DefinitelyTyped. Specifically these lines:
/**
* Middleware for express; takes an options object or function as input to
* configure behavior, and returns an express middleware.
*/
export default function graphqlHTTP(options: Options): Middleware;
Ideally, it should be:
var graphqlHTTP: (options: Options) => Middleware;
/**
* Middleware for express; takes an options object or function as input to
* configure behavior, and returns an express middleware.
*/
export = graphqlHTTP;
You can import graphqlHTTP using the following import statement:
import * as graphqlHTTP from 'express-graphql';
Closing this here since it sounds like a bug in that repo
Most helpful comment
You can import graphqlHTTP using the following import statement:
import * as graphqlHTTP from 'express-graphql';