We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
Wonderful Tutorial! Thank you so much for making it!
will you please add subscription as well in your code
Thank you, great article.
Getting an error that I'm not sure how to resolve
when I run npm start in the terminal, it throws this error
TypeError: graphqlHttp is not a function
Here's my code
const express = require("express")
const graphqlHttp = require("express-graphql")
const mongoose = require("mongoose")
const graphqlSchema = require("./graphql/schema")
const graphqlResolvers = require("./graphql/resolvers")
const app = express()
app.use(
"/graphql",
graphqlHttp({
schema: graphqlSchema,
rootValue: graphqlResolvers,
graphiql: true,
})
)
const { graphqlHTTP } = require("express-graphql");
app.use(
"/graphql",
graphqlHTTP({
schema: buildSchema(`
I think the import should have graphqlHTTP wrapped in curly brackets
Wait, I was think about that wrong. Yes, looking at the documentation on npm, it does simply show putting curly brackets at the import. However, I'm still getting the same error. Still looking into.
Thanks for your answer btw
Sorry, not 100% sure where you mean by at the import.
yeah, I meant const {graphqlHTTP} = require("express-graphql")
what is the error you are getting now?
Also, check that that HTTP should be all caps in graphqlHTTP instead of graphqlHttp
Cool
Yup, my issue was the the HTTP in my graphqlHTTP import was lower case.
Changed it to
const graphqlHTTP = require('express-graphql")Thanks to both of you guys