相关疑难解决方法(0)

graphqlHTTP 不是函数

这是我的简单 graphql express 应用程序

const express = require('express');
const graphqlHTTP = require('express-graphql');

const app = express();
app.use(
    '/graphql',
    graphqlHTTP({
      graphiql: true,
    })
  );

app.listen(4000, () => {
    console.log("listening for request!");
});
Run Code Online (Sandbox Code Playgroud)

我在运行时遇到以下错误:

 graphqlHTTP({
    ^

TypeError: graphqlHTTP is not a function
    at Object.<anonymous> (D:\PersonalProjects\GraphQL\server\app.js:7:5)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)  
    at internal/main/run_main_module.js:17:47
Run Code Online (Sandbox Code Playgroud)

我该如何解决?提前致谢!

javascript node.js express graphql express-graphql

48
推荐指数
5
解决办法
2万
查看次数

标签 统计

express ×1

express-graphql ×1

graphql ×1

javascript ×1

node.js ×1