Here it is in its current state:
export const checkFetcher = (fetcher: GlobalFetch['fetch']) => {
if (!fetcher && typeof fetch === 'undefined') {
let library: string = 'unfetch';
if (typeof window === 'undefined') library = 'nodefetch';
throw new Error(`
fetch is not found globally and no fetcher passed, to fix pass a fetch for
your environment like https://www.npmjs.com/package/${library}.
For example:
import fetch from '${library}';
import { createHttpLink } from 'apollo-link-http';
const link = createHttpLink({ uri: '/graphql', fetch: fetch });`);
}
};
nodefetch does not exist.import fetch from 'node-fetch' would break the client. The right advice is to just use import 'isomorphic-unfetch' and not mess around with passing fetch into the link config.apollo-link-http in the message might confuse people using other http packages, such as batching or uploads.invariant).https://www.npmjs.com/package/ could be https://npm.im/, along with other tweaks to shorten the message.I already shared some of these points:
@jaydenseric Here to point out that I stumbled upon this today and installing and importing isomorphic-unfetch got rid of the warning for me.
npm i isomorphic-unfetch
And, on the server:
// Importing `isomorphic-unfetch` due to `apollo-link-http` raising
// a warning of not having `fetch` globally available.
// @see https://github.com/apollographql/apollo-link/issues/493
import 'isomorphic-unfetch';
import { createHttpLink } from 'apollo-link-http';
Most helpful comment
@jaydenseric Here to point out that I stumbled upon this today and installing and importing
isomorphic-unfetchgot rid of the warning for me.And, on the server: