Intended outcome:
I'm just trying to import the following into my React Native app, as seen in the docs:
import {execute, HttpLink} from 'apollo-link';
Actual outcome:
However, upon simply injecting this line, my React Native app immediately errors:
<Error>: Can't find variable: self
<Critical>: Unhandled JS Exception: Can't find variable: self
<Error>: undefined is not an object (evaluating 'require(487 ).default')
<Critical>: Unhandled JS Exception: undefined is not an object (evaluating 'require(487 ).default')
<Error>: Requiring module "myapp/src/config/Apollo.js", which threw an exception: Error: Requiring module "917", which threw an exception: ReferenceError: Can't find variable: self
<Error>: Requiring module "917", which threw an exception: ReferenceError: Can't find variable: self
How to reproduce the issue:
All I did was attempt to import the library, so I imagine that's all that is required.
Any insight as to what might be wrong? Some more info:
apollo-link version: 0.5.4
react-apollo version: 1.4.15
react-native version: 0.48.1
react version: 16.0.0-alpha.12
This library depends on apollo-fetch and apollo-fetch depends on isomorphic-fetch.
isomorphic-fetch has issues with React Native...
Oh hm... Guess I'll just have to wait out a fix then. Thanks for the insight!
@Nickersoft if you don't feel like waiting, or rolling your own ApolloLink, do this...
https://github.com/matthew-andrews/isomorphic-fetch/issues/125#issuecomment-310717036
@affablebloke are you suggesting forking isomorphic-fetch?
if not, where do you place the following _fix_?

Cheers!
@CaryLandholt
It depends on your project's setup. I have placed this line at the top of App.js. Or you could place it at the top of both index.android.js and index.ios.js.
// Fixes isomorphic-fetch
GLOBAL.self = GLOBAL;
Doing this before any imports of isomorphic-fetch will monkey patch the GLOBAL object for React Native.
@affablebloke worked perfectly - thanks!
The apollo-link-http no longer uses global fetch so this shouldn't be a problem! I'll be updating the batching fetch in the new few weeks to do the same!
@jbaxleyiii would be really nice to have batch use the global fetch too!
is batch-http now using global fetch? still facing this error with [email protected]
@jbaxleyiii
Most helpful comment
@CaryLandholt
It depends on your project's setup. I have placed this line at the top of
App.js. Or you could place it at the top of bothindex.android.jsandindex.ios.js.Doing this before any imports of
isomorphic-fetchwill monkey patch theGLOBALobject for React Native.