apollo-client icon indicating copy to clipboard operation
apollo-client copied to clipboard

CurrentFetch is Not a function

Open JoymenOpoyi opened this issue 2 years ago • 8 comments

$currentFetch is not a function. (In 'currentFetch(chosenURI, options)', 'currentFetch is false') Few days ago everything was working properly in my react native app and then suddenly I get this issue in all of my queries

Intended outcome: to get a data response from the query and the screen get loaded

Actual outcome: image Whenever I run the app and I am getting this error on all the queries which are being fired in the app.

How to reproduce the issue: I am using an IOS Emulator of iPhone X and it doesnt work over there, but strangely in my android device which i run through adb evrything just works fine

Versions System: OS: macOS 12.2

Binaries: Node: 14.16.1 - /usr/local/bin/node npm: 8.2.0 - /usr/local/bin/npm

Browsers: Firefox: 98.0.2 Safari: 15.3

npmPackages: @apollo/client: ^3.3.6 => 3.5.7

JoymenOpoyi avatar Apr 07 '22 18:04 JoymenOpoyi

I have the same issue, plss someone provide the solution.

VensonOpoyi avatar Apr 07 '22 18:04 VensonOpoyi

Yeah even I am facing the same issue, if you encounter upon any solution to this problem, do respond.

Ninad-Opoyi avatar Apr 07 '22 18:04 Ninad-Opoyi

@benjamn can you take a look?, I saw a previous issue where you had worked on currentFetch

JoymenOpoyi avatar Apr 08 '22 04:04 JoymenOpoyi

Same error here with react-native. Anyone found a solution?

var currentFetch = preferredFetch || utilities.maybe(function () { return fetch; }) || backupFetch;

I see this line returns false which is a boolean not a function. And even if I set fetch option on the HttpLink I get a similar error

evenSosaAkido avatar Jun 01 '22 17:06 evenSosaAkido

fwiw, I have the same problem in node.

I have no idea if this will help for react native.

I included cross-fetch in the default HttpLink and it works for me. It did not work using node-fetch which is annoying.

My fix was

const fetch = require('cross-fetch');
//....
const client = new ApolloClient({
      cache: new InMemoryCache(),
      link: new HttpLink({
        fetch,
      })
});

armordog avatar Jun 01 '22 18:06 armordog

@evenSosaAkido were you ever able to resolve this? Setting fetch is also not working for me.

daniel-covelli avatar Sep 19 '22 23:09 daniel-covelli

@daniel-covelli the issue was resolved in a very unexplicable way for us. I don't know if you use okta. But it tuned out for us that the order we imported the libraries (okta and apollo) caused this error.

So importing apollo BEFORE okta fixed the issue for us.

Sorry I can't give a better answer

evenSosaAkido avatar Sep 20 '22 16:09 evenSosaAkido

@evenSosaAkido yes I believe we are running into the same issue. In our codebase this manifested in our hooks subfolder, by exporting a hook that used @okta before a hook that used @apollo, this error would occur. Weird!

daniel-covelli avatar Sep 21 '22 17:09 daniel-covelli

👋 If anyone has a runnable reproduction here, or can create one using our RN testbed https://github.com/apollographql/rn-apollo-client-testbed, that would be much appreciated!

alessbell avatar Apr 18 '23 19:04 alessbell

We're closing this issue now but feel free to ping the maintainers or open a new issue if you still need support. Thank you!

github-actions[bot] avatar May 19 '23 05:05 github-actions[bot]

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. For general questions, we recommend using StackOverflow or our discord server.

github-actions[bot] avatar Jun 19 '23 00:06 github-actions[bot]