graphql-rest-wrapper icon indicating copy to clipboard operation
graphql-rest-wrapper copied to clipboard

TypeError: gqlRestWrapper is not a constructor

Open alwaysLearning1 opened this issue 7 years ago • 1 comments

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())

alwaysLearning1 avatar Aug 03 '17 16:08 alwaysLearning1

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
})

pascalc avatar Sep 17 '17 17:09 pascalc