Graphql-yoga: Cannot instantiate GraphQLServer - "Cannot set property `subscriptionServerOptions` of undefined"

Created on 16 Apr 2019  路  1Comment  路  Source: dotansimha/graphql-yoga

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**

Most helpful comment

Hi @rumansaleem - you need to instantiate the server with new:

const server = new GraphQLServer({

>All comments

Hi @rumansaleem - you need to instantiate the server with new:

const server = new GraphQLServer({

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asci picture asci  路  3Comments

frederikhors picture frederikhors  路  4Comments

lautiamkok picture lautiamkok  路  4Comments

checkmatez picture checkmatez  路  5Comments

playerx picture playerx  路  5Comments