Skip to content
This repository has been archived by the owner on Aug 20, 2020. It is now read-only.

Dropped dependency isomorphic-fetch in favor of cross-fetch (React Native compatible) #71

Merged
merged 1 commit into from
Dec 5, 2017

Conversation

lquixada
Copy link
Contributor

@lquixada lquixada commented Oct 5, 2017

isomorphic-fetch has a bug that prevents it from running in a react native environment. Since it is no longer maintained, it will never be fixed. That also means dependencies are outdated. cross-fetch is React Native compatible.

@apollo-cla
Copy link

@lquixada: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@lquixada
Copy link
Contributor Author

lquixada commented Oct 6, 2017

@evans I did a small contribution here since isomorphic-fetch is outdated. hope it's useful to you as it is for me.

@ctavan
Copy link
Contributor

ctavan commented Oct 6, 2017

Please also consider #30 (it basically includes this patch as well).

@evans
Copy link
Contributor

evans commented Oct 6, 2017

@lquixada This is great!

@ctavan Thank you!

My proposal moving forward is to merge this and publish a 0.7, then merge the jest/apollo-fetch-polyfill from #30 with a publish to 1.0, since I think it's what we want apollo-fetch and a breaking change. How does that sound? CC @jbaxleyiii

@ctavan
Copy link
Contributor

ctavan commented Oct 6, 2017

I'm totally fine with that @evans!

I just ported the test suite to jest in my other branch… Will need a few more minutes to get things running with lerna as well.

@lquixada
Copy link
Contributor Author

@evans @jbaxleyiii any news here?

@michaelknoch
Copy link

michaelknoch commented Nov 13, 2017

@ctavan
Copy link
Contributor

ctavan commented Nov 13, 2017

@michaelknoch the issue you're seeing should be independent of apollo-fetch. apollo-client@2.x now uses apollo-link-http which no longer comes with a fetch polyfill or ponyfill, see https://github.com/apollographql/apollo-link/tree/master/packages/apollo-link-http#global-fetch

Have you tried passing your own ponyfill or polyfilling fetch on your own?

@michaelknoch
Copy link

@ctavan
where shall i pass the ponyfill into? is it possible to pass fetch into apollo-link?

@ctavan
Copy link
Contributor

ctavan commented Nov 13, 2017

@michaelknoch please just refer to the documentation: https://github.com/apollographql/apollo-link/tree/master/packages/apollo-link-http#global-fetch

The HTTP Link relies on having fetch present in your runtime environment. If you are running on react-native, or modern browsers, this should be no problem. If you are targeting an environment without fetch such as older browsers of the server, you will need to pass your own fetch to the link through the options. We recommend unfetch for older browsers and node-fetch for running in node.

And: https://github.com/apollographql/apollo-link/tree/master/packages/apollo-link-http#options

fetch: a fetch compatiable API for making a request

So in short: You just use your favorite fetch ponyfill (https://github.com/lquixada/cross-fetch or the more lightweight https://github.com/developit/unfetch) and pass it as an option to the HttpLink constructor.

@evans evans merged commit a378f3c into apollographql:master Dec 5, 2017
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 this pull request may close these issues.

5 participants