-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Class constructor DataSource cannot be invoked without 'new' using Babel #2216
Comments
For anyone that runs into this problem - I solved it by adding this to my
|
Did not solve it for me :-( |
@vaskaloidis Yes, this can be avoided by not transpiling @mschipperheyn Do you have a Babel configuration in place that you could share? What version of Node.js are you using? |
@abernix I fixed this using babel.config.js:
|
@vaskaloidis As you said, adding:
Solved the problem This is my .babelrc:
|
I successfully solved this issue with babel-preset-latest-node My .babelrc:
|
Closing this because the issue has been solved above. |
How do I do if I'm using the typescript compiler ? |
@NitroBAY same question here |
@NitroBAY , @ahouzzer , here is solution for TS: |
Without this, we'll get a 'Class constructor JSONPlaceholder cannot be invoked without 'new'' error message Source: apollographql/apollo-server#2216 (comment)
To future readers: I solved this problem setting
|
I created my own Custom DataSource class using Knex as the backend, but I keep getting this error about my call to the DataSource superclass:
Class constructor DataSource cannot be invoked without 'new' using Babel
I read the previous issues pertaining to this error, and everybody solved it by simply upgrading to es6+ but I am using the latest ECMA and it is still happening.
The issue is with the super() here:
For reference, here is my server definition:
Here is the DataSource's usage:
I am running
@babel/core
,@babel/runtime
@babel/node
and "@babel/preset-env" all~7.2.0
- still to no avail. Also the error is returned when I try and run queries in the Playground - queries that previously worked until I setup the DataSource. Instead of the data, it returns the error about the call to super(). Nothing in the console.The text was updated successfully, but these errors were encountered: