SyntaxError: Unexpected token ‘export’

--

If you are using require like:

const schema = require(‘./schema.js’);

and you have exported in schema.js like:

export default new GraphQLSchema({query: RootQuery});

In case you are getting error like ‘Unexpected token export’ while starting the server, then export like below in schema.js

exports.schema = new GraphQLSchema({query: RootQuery});

or

module.exports = new GraphQLSchema({query: RootQuery});

--

--