I changed the codes multiple times for this part but it still showing errors, I don't know where else I should change the code. Yes, I did tried the methods from the previous post about graphqlHttp is not a function but I'm still getting the errors
errors: C:UsersjustjDocumentsWeb ProjectMERN Stack
Projectsevent-bookingapp.js:35 app.use('/graphql', graphqlHttp({
TypeError: graphqlHttp is not a function
at Object.<anonymous> (C:UsersjustjDocumentsWeb ProjectMERN Stack Projectsevent-bookingapp.js:35:21)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 [nodemon] app crashed - waiting for file changes before starting...
Code:
const express = require('express');
const bodyParser = require('body-parser');
const {graphqlHTTP} = require('express-graphql');
app.use('/graphql', graphqlHTTP({
schema: buildSchema(`
type RootQuery {
events: [String!]!
}
type RootMutation {
createEvent(name: String): String
}
schema {
query: RootQuery
mutation: RootMutation
}
`),
rootValue: {
events: () => {
return ['Cooking', 'Sailing', 'Coding'];
},
createEvent: (args) => {
const eventName = args.name;
return eventName;
}
},
graphiql: true
})
);
question from:
https://stackoverflow.com/questions/65876020/need-to-use-the-graphqlhttp-function-by-importing-it-from-graphql-package-but-it 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…