-
Notifications
You must be signed in to change notification settings - Fork 344
zen-observable import breaks queries in apollo-client when transpiled #248
Comments
I have a same problem but with difference error. My code is here. import 'isomorphic-fetch'
import { ApolloLink } from 'apollo-link'
import { ApolloClient } from 'apollo-client'
import { HttpLink } from 'apollo-link-http'
import { InMemoryCache } from 'apollo-cache-inmemory'
export default new ApolloClient({
link: new HttpLink({ uri: 'http://localhost:5000/api/graphql' }),
cache: new InMemoryCache()
})
I tried this work arround and I got same error with @stevestreza 's one. import 'isomorphic-fetch'
import * as apolloLink from 'apollo-link'
import Observable from 'zen-observable'
apolloLink.Observable = Observable |
@stevestreza @mizchi what versions of apollo-client and apollo-link are you using? |
Same problem here, with [email protected] in a webpack project, fixed by removing the |
Same issue here. |
Same here, and would like to add the issue isn't within Webpack, as written on SO, but in Apollo and/or TypeScript. Reason I know is that I am using Rollup to create a bundle instead of Webpack. |
I think this is a TypeScript + Rollup bug but I'm surprised it isn't manifesting in our own Rollup builds. Would anyone here be up to opening a pull request making the change suggested above? |
Same issue here with Rollup. I'm not using Typescript either. |
Looks like TS is all screwed up. I tried building the module to fix the errors but was getting TS errors. |
Hello pardon my asking but does anyone have a hotfix while this is being resolved? any idea what the last stable version was? |
in my investigations so far i think this problem only occurs outside of create-react-app. so there is some implicit assumption inside create-react-app that is not being documented that is causing this |
Same issue here, I just followed the doc on a brand new project and got this error. I'm unable to continue with Apollo. |
just linking my other issue here: apollographql/apollo-client#2785 (comment) where there is a proposed fix (i have not tested) |
not sure if this is related but... im using rollup to create a bundle for a very simple react app. everything is working fine until i try to introduce apollo-client into the mix.. following the documentation here: https://www.apollographql.com/docs/react/basics/setup.html#installation after trying to build the project with rollup i get the following error during the build:
ive tried changing the import in |
I am facing an issue with zen-observable which is quite different. please have a look at |
I am so struggling that I have no choice but to use the following hack to get around with this issue... webpack.config.js {
test: /node_modules\/apollo-link.*?\/lib\/.*?.js/,
loader: 'string-replace-loader',
options: {
search: 'exports.Observable = Observable',
replace: 'exports.Observable = Observable.default'
}
}, I really wish I can get some helps here so i can remove this hack... P.S. I do not use TypeScript but just babel. Not sure if this is the reason why it is broken to me |
I get the same error without typescript and I can vouch that making the change
fixes the issue |
damn @kinyat i had no idea you could do that with webpack. TIL!!! thank you!!! |
Same issue in a basic Hello World app with |
@alapini I think one of the "legal" solutions is for Apollo to provide non-typescript user (i.e. Babel) a ES5 version from the ts complier. |
I'm using apollo for my vuex-orm-apollo plugin and changing files within the |
with the latest version of typescript the imports can be expressed in normal es modules syntax, so maybe if we all wait for Apollo to upgrade the typescript version this will work out of the box for us non TS users. |
I think I'm running into some of the same issues listed here. First time using apollo, so I am not 100% sure if I'm connecting things correctly. I'm using rollup without typescript with inferno. The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
'of' is not exported by 'node_modules/zen-observable/index.js'
'of' is not exported by 'node_modules/zen-observable/index.js'
'of' is not exported by 'node_modules/zen-observable/index.js'
(node:37350) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: 'print' is not exported by node_modules/graphql/language/printer.js
(node:37350) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code |
For those using parcel.js, this PR seems to temp fix the issue: parcel-bundler/parcel#530 I haven't dived too deep into this problem, but it seems that the core of the issue, as @fathyb notes here, is:
So it seems that the workaround @stevestreza posted (removing Fwiw, I was getting the |
I'm having this issue as well using Rollup in a Vuejs project. |
thanks for sharing @tadas412 |
The above PR was published in 1.2.0. Let me know if it still isn't resolved! |
still getting an error with 1.2.0 😢
this seems to be tracked here apollographql/apollo-client/issues/2785 as well |
For me, it works with 1.2.0. @littletower That may sound stupid, but are you sure, you're using 1.2.0? Maybe delete the node_modules dir and reinstall the packages? Just asking :) |
@phortx yeah I did that already :( |
@littletower That's odd. I was getting the same error with 1.1.0 and 1.2.0 seemed to resolve it. |
The change definitely fixed the actual code-level issue, but it looks like
I'm past my knowledge at this point on how yarn works to fix this (I would expect it to have installed Either way, though, this seems fully fixed here! |
@evans I created a repo for reproduction and guess what? I'm not having the issue, but in my original code I still do... I'll investigate further. Thanks for the feedback! |
I'm getting the same error in a Polymer 3 project and import { HttpLink } from 'apollo-link-http'; causes
|
@heruan Did you find any solution? I am facing the same issue. |
Hi there!
I'm working to get a new project set up with Apollo Client, Apollo Link, babel, and webpack. I use a pretty simple project template to set it up with the documented suggestions in Apollo Client. When I go to run it and send it a query, I get a runtime exception and queries cannot go through. I traced this to how the
zen-observable
package is imported.Intended outcome:
Apollo Client can make a query using Apollo Link, using the following code:
Actual outcome:
Apollo Client throws the following exception:
The
ObservableQuery
imports theObservable
from the Apollo Link project, which imports it from thezen-observable
package. When transpiled to JavaScript, the apollo-link package has this atlib/index.js
:It seems that this causes some strange case when transpiling and later subclassing this Observable, but this seems to be where the
call
method stops being available through my investigation.How to reproduce the issue:
Attached is a test project which should demonstrate the issue. I assume Node.js v6 or v8 installed with Yarn. Test Project
yarn install
yarn run start
and open http://localhost:3000/You can workaround this by changing
node_modules/apollo-link/lib/index.js:3
from:import * as Observable from 'zen-observable';
to:
import Observable from 'zen-observable';
The problem is if you make this change in the corresponding .ts file, it causes a linting failure, and I'm not sure how best to resolve that.
There is this issue on StackOverflow which suggests that other people are having this issue.
Thank you so much for your time, for looking at my bug report, and for the awesome work on Apollo!
The text was updated successfully, but these errors were encountered: