GraphQL error : Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm

Viewed 151

I am trying the following code from TutorialPoint's website for my GraphQL implementation. from the Tutorial Points example : GraphQL link.

const bodyParser = require('body-parser')
const cors = require('cors')
const express = require('express')
const port = process.env.PORT||9000
const app = express()

app.use(bodyParser.json() , cors())
const typeDefinition = `
type Query  {
   greeting: String
}`
const  resolverObject = {
   Query : {
      greeting: () => 'Hello GraphQL  From TutorialsPoint !!'
   }
}
const {makeExecutableSchema} = require('graphql-tools')

const schema = makeExecutableSchema({typeDefs:typeDefinition, resolvers:resolverObject})

const {graphqlExpress,graphiqlExpress} = require('apollo-server-express')

app.use('/graphql',graphqlExpress({schema}))
app.use('/graphiql',graphiqlExpress({endpointURL:'/graphql'}))
app.listen(port, () =>  console.log(`server is up and running ${port}`))

But the issue is that when I run the above code as mentioned in the tutorial. I am running into the following error. enter image description here

I have installed all the mentioned dependencies and ran the code through

http://localhost:9000/graphiql

I am not able to figure out what the issue is.

0 Answers
Related