graphql-rest-wrapper
graphql-rest-wrapper copied to clipboard
TypeError: gqlRestWrapper is not a constructor
I am getting 'TypeError: gqlRestWrapper is not a constructor' for code below, please advise what's missing? did anyone encounter this issue?
const wrapper = new gqlRestWrapper('http://localhost:9090/restapi', { name: 'MyRestAPI', generateSchema: true, saveSchema: true, graphiql: true })
app.use('/graphql', wrapper.expressMiddleware())
This happens when you require('graphql-rest-wrapper')
but it's exported as an ES6 module, so you have to do:
const gqlRestWrapper = require("graphql-rest-wrapper").default
Then you can do
const wrapper = new gqlRestWrapper(endpoint, {
name: "fooBar",
generateSchema: true,
saveSchema: true,
graphiql: true
})