Here's what i did.
// index.js
const { GraphQLServer } = require('graphql-yoga')
const server = GraphQLServer({
typeDefs: `
type Query {
hello(name: String): String!
}
`,
resolvers: {
Query: {
hello: (_, {name}) => `Hello ${name || World}`
}
}
});
server.start(() => console.log('Server is running on http://localhost:4000'))
when I run the server using node index.js, I am presented with the following error message:
/hdd/code/fun-learn/learn-graphql/server/node_modules/graphql-yoga/dist/index.js:75
this.subscriptionServerOptions = null;
^
TypeError: Cannot set property 'subscriptionServerOptions' of undefined
at GraphQLServer (/hdd/code/fun-learn/learn-graphql/server/node_modules/graphql-yoga/dist/index.js:75:40)
at Object.<anonymous> (/hdd/code/fun-learn/learn-graphql/server/src/index.js:61:16)
at Module._compile (internal/modules/cjs/loader.js:805:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:816:10)
at Module.load (internal/modules/cjs/loader.js:672:32)
at tryModuleLoad (internal/modules/cjs/loader.js:612:12)
at Function.Module._load (internal/modules/cjs/loader.js:604:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:868:12)
at internal/main/run_main_module.js:21:11**
Hi @rumansaleem - you need to instantiate the server with new:
const server = new GraphQLServer({
Most helpful comment
Hi @rumansaleem - you need to instantiate the server with
new:const server = new GraphQLServer({