You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run into an issue while trying to pass a custom fetch function to allow a client to play nice with IE 11. After a little digging, it appears as though the fetch function never actually gets passed to HttpLink, since fetchOptions is passed but never spread to set fetch. I think part of the confusion may be related to the naming of the fetchOptions property on the PresetConfig interface. Seems like a more appropriate name might be linkOptions, since HttpLink.Options contains both fetch and fetchOptions properties.
Actual outcome:
Receive a console error:
fetch is not found globally and no fetcher passed, to fix pass a fetch for
your environment like https://www.npmjs.com/package/unfetch.
For example:
import fetch from 'unfetch';
import { createHttpLink } from 'apollo-link-http';
const link = createHttpLink({ uri: '/graphql', fetch: fetch });
How to reproduce the issue:
importApolloClientfrom'apollo-boost';importfetchfrom'unfetch';// Produces an error on IE 11.constclient=newApolloClient({fetchOptions: { fetch },uri: process.env.GRAPHQL_API_URL,});
I think one solution to resolving my issue and a fewother issues and PRs related to setting the credentials property may be to simply spread the fetchOptions/linkOptions to overwrite the default values if they exist on the config object.
Intended outcome:
I've run into an issue while trying to pass a custom fetch function to allow a client to play nice with IE 11. After a little digging, it appears as though the
fetch
function never actually gets passed toHttpLink
, sincefetchOptions
is passed but never spread to setfetch
. I think part of the confusion may be related to the naming of thefetchOptions
property on thePresetConfig
interface. Seems like a more appropriate name might belinkOptions
, sinceHttpLink.Options
contains bothfetch
andfetchOptions
properties.Actual outcome:
Receive a console error:
How to reproduce the issue:
I think one solution to resolving my issue and a few other issues and PRs related to setting the
credentials
property may be to simply spread thefetchOptions
/linkOptions
to overwrite the default values if they exist on theconfig
object.Version
The text was updated successfully, but these errors were encountered: