Skip to content
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

Latest version of React Native + Apollo Stack doesn't work. #261

Closed
saeho opened this issue Jun 2, 2016 · 21 comments · Fixed by #357
Closed

Latest version of React Native + Apollo Stack doesn't work. #261

saeho opened this issue Jun 2, 2016 · 21 comments · Fixed by #357
Assignees

Comments

@saeho
Copy link

saeho commented Jun 2, 2016

Following this example I'm able to get Apollo working:
#147 (comment)

But then, this happens:

$export is not a function. (In '$export($export.S+$export.F*~require(740 /* ./_descriptors*/),'Object',
...

Thus the React Native app cannot run with Apollo.

@saeho
Copy link
Author

saeho commented Jun 2, 2016

Just figured out the issue. It's very strange.

"npm install" creates a sub-node_modules folder inside the "APP/node_modules/graphql/" module directory.

Deleting this second node_modules folder from the graphql folder will make the app work again.

Inside this inner node_modules folder, there are 2 packages -- babel-runtime and core-js. Deleting these make the apollo app work again.

@helfer
Copy link
Contributor

helfer commented Jun 2, 2016

@saeho Is this something we can fix with a prepublish or postinstall script, or is it an npm issue we have no control over?

@saeho
Copy link
Author

saeho commented Jun 2, 2016

I'm trying to figure this out too.

The reason why I'm posting this here is because I think it's an apollo issue.

Apollo used to work in the React Native app I'm working on at one point. Then after some upgrades (don't know which package), I learned that my co-workers cannot fresh-install the app and make it run with npm install.

The package causing this issue as I said above is the graphql package. And Apollo-client/react-apollo is the only graphql related package in my react-native app. (Server is in a completely different repo so no server graphql packages can be causing this).

@helfer
Copy link
Contributor

helfer commented Jun 2, 2016

This sounds a lot like an npm issues (npm has so many issues... ), but there may be a workaround.

If you could make a github repo with a minimal reproduction, then we might have a chance at figuring out whether there's a fix we can do in apollo client, or whether this needs to be fixed in graphql-js.

@tychota
Copy link

tychota commented Jun 2, 2016

@saeho can you post your npm and node version. Seems like an npm2 artifacts. Npm3 normally flatten the tree.

@saeho
Copy link
Author

saeho commented Jun 2, 2016

npm 3.8.6
node 5.10.1

@stubailo
Copy link
Contributor

stubailo commented Jun 2, 2016

Perhaps graphql somehow depends on babel-runtime and babel-runtime is not compatible with Apollo Client?

And then maybe when you delete that package, it still runs fine because the GraphQL parser (the only part of graphql we use in Apollo Client) doesn't use anything from babel-runtime?

That could be one explanation.

@saeho
Copy link
Author

saeho commented Jun 2, 2016

That's probably what's happening. But the question is not why it breaks, but why it's happening.

@helfer
Copy link
Contributor

helfer commented Jun 2, 2016

Why would graphql depend on babel-runtime? (except during development)

Maybe this is an extraneous dependency in graphql, and could be removed there?

From what I understand, babel-runtime gets compiled into the app during build, so there should be no runtime dependency on any babel packages.

@saeho
Copy link
Author

saeho commented Jun 6, 2016

After some digging around, I came to the conclusion that graphql's babel-runtime dependency is causing this issue. Can we please remove it from the its dependencies?

@stubailo
Copy link
Contributor

stubailo commented Jun 6, 2016

I think a good choice would be submitting a PR to graphql-js to remove the dependency on babel-runtime and turn off the babel runtime transform, and see what Lee thinks. When I talked to him before he seemed interested in making GraphQL-JS something you can reasonably use on the client, and React Native is a pretty attractive use case, so perhaps he would be interested in this change.

@helfer
Copy link
Contributor

helfer commented Jun 12, 2016

@saeho Any news on this? Did you file an issue or make a PR to graphql-js?

@arealmaas
Copy link

followed the same steps as @saeho, but got this error:

One of the sources for assign has an enumerable key on the prototype chain. This is an edge case that we do not support. This error is a performance optimization and not spec compliant.

It's when using object-assign in connect.js in react-apollo, so issue probably belongs in that repo. But you didn't receive this error?

React native doesn't like modules to use object-assign-polyfill?

@arealmaas
Copy link

arealmaas commented Jun 22, 2016

Did you get this to work @saeho ? Seems like babel-deps that graphql needs breaks react native packaging.

EDIT: Seems like apollostack doesn't like immutable data. So that was my issue

@tychota
Copy link

tychota commented Jun 25, 2016

I also have the same issue, @saeho ! Do you want me to file an issue ?

@tlvenn
Copy link

tlvenn commented Jul 1, 2016

Is there any update on this issue ? I read on Slack that @stubailo wanted to take a closer look and fix any remaining issue with RN. Did you had a chance to do it yet ?

@stubailo
Copy link
Contributor

stubailo commented Jul 1, 2016

OK here's the plan: We're going to bundle just the print and parse functions of graphql into the graphql-tag package, and remove the dependency altogether.

@abhiaiyer91 is going to take a stab at it, and we'll see if we can get it done today.

@arealmaas
Copy link

👋👋
On Fri, 1 Jul 2016 at 19:28 Sashko Stubailo notifications@github.com
wrote:

OK here's the plan: We're going to bundle just the print and parse
functions of graphql into the graphql-tag
https://github.com/apollostack/graphql-tag package, and remove the
dependency altogether.

@abhiaiyer91 https://github.com/abhiaiyer91 is going to take a stab at
it, and we'll see if we can get it done today.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#261 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABse1vJ2yheJtkqIbKiHRCkNVGTp2Kx6ks5qRU4jgaJpZM4IsJvJ
.

@tychota
Copy link

tychota commented Jul 2, 2016

@stubailo @abhiaiyer91 : i started to investiguate this solution last week so maybe I can help.

But are you sure you wan't to maintain a fork for those two functions if graphql agrees to split package and remov the hard dependencie to async in the parser build.

@abhiaiyer91
Copy link
Contributor

@tychota yes ideally we would want graphql to be more modular in their export. I also even tried to attempt the solution like that, but since we use these 2 functions only, I felt that it was too much work to sign up for to unblock our project

apollographql/graphql-tag#3

Here is the PR. We just bundle parser and printer, and if graphql does change this we can always rebundle.

@stubailo
Copy link
Contributor

stubailo commented Jul 6, 2016

OK, I believe we have conclusively fixed this issue in Apollo Client version 0.3.27, which now depends on graphql-tag, which contains a pre-bundled GraphQL printer and parser to avoid the build issues. Let me know if this doesn't work! Big thanks to @abhiaiyer91 for building the bundle script.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants