IE 11 compatibility Apollo Client@2.x
See original GitHub issueIntended outcome:
- browser: IE 11
- apollo client@2.x has compatibility
Actual outcome:
throw error:
throw"undefined"==typeof window&&(e="node-fetch"),new Error("fetch is not found globally and no fetcher passed, to fix pass a fetch for\n your environment like https://www.npmjs.com/package/"+e+".\n\n For example:\n import fetch from '"+e+"';\n import { createHttpLink } from 'apollo-link-http';\n\n const link = createHttpLink({ uri: '/graphql', fetch: fetch });\n ")}}
If show that I should use apollo-client@1.x ?
How to reproduce the issue:
- package.json
"dependencies": {
"antd": "^3.0.1",
"apollo-cache-inmemory": "^1.1.2",
"apollo-client": "^2.1.0",
"apollo-link-error": "^1.0.2",
"apollo-link-http": "^1.3.0",
"babel-polyfill": "^6.26.0",
"babel-runtime": "^6.9.2",
"classnames": "^2.2.5",
"core-js": "^2.5.1",
"dva": "^2.1.0",
"dva-loading": "^1.0.4",
"g-cloud": "^1.0.2-beta",
"g2": "^2.3.13",
"g2-plugin-slider": "^1.2.1",
"graphql": "^0.11.7",
"graphql-tag": "^2.5.0",
"lodash": "^4.17.4",
"lodash-decorators": "^4.4.1",
"lodash.clonedeep": "^4.5.0",
"moment": "^2.19.1",
"numeral": "^2.0.6",
"prop-types": "^15.5.10",
"qs": "^6.5.0",
"react": "^16.0.0",
"react-apollo": "^2.0.1",
"react-container-query": "^0.9.1",
"react-document-title": "^2.0.3",
"react-dom": "^16.0.0",
"react-fittext": "^1.0.0"
},
/*Creating a client*/
import { ApolloClient } from 'apollo-client';
import { HttpLink } from 'apollo-link-http';
import { InMemoryCache } from 'apollo-cache-inmemory';
import errorHandler from './errorHandle'
const urlDomain =process.env.NODE_ENV == "development" ? 'charity.beta.xchanger.cn' : location.href.includes("beta") ? 'charity.beta.xchanger.cn' : 'charity.xchanger.cn'
const httpLink = new HttpLink(
{ uri: 'http://'+urlDomain+'/graphql' ,
headers:{ 'Authorization':localStorage.accessToken },
});
const client = new ApolloClient({
link: errorHandler.concat(httpLink),
cache: new InMemoryCache(),
defaultOptions:{
query: {
fetchPolicy: 'network-only',//强制从服务器获取数据
errorPolicy: 'all',
},
mutate: {
errorPolicy: 'all'
},
}
});
/*Creating a provider*/
import { ApolloProvider } from 'react-apollo';
export default { ApolloProvider,client }
Version
- apollo-client@2.1.0
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Advanced HTTP networking - Apollo GraphQL Docs
A fetch -compatible API for making a request. See Providing a fetch replacement for certain environments. headers, An object containing header names and...
Read more >@apollo/client | Yarn - Package Manager
Apollo Client is a fully-featured caching GraphQL client with integrations for React, Angular, and more. It allows you to easily build UI components...
Read more >Tips and tricks to manage Internet Explorer compatibility
Enterprise Mode for Internet Explorer 11 can be very effective in providing backward compatibility for older web apps. The Enterprise Mode Site ...
Read more >apollo npm
Explore Tumblr Posts and Blogs tagged as # apollo x male reader with no restrictions ... Compatible with all popular JavaScript frameworks and...
Read more >How do I add support of vue-apollo for IE11? - Stack Overflow
I'm working on MEVN stack with GraphQL implementation. I had problems displaying my Vue application on IE11, but then I added babel-polyfill ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is expected to happen as you have to add a polyfill for fetch yourself, such as
isomorphic-unfetch
:And then, at the top of your imports when creating the client:
If you are not server side rendering, you could use
unfetch
directly instead.Unfetch didn’t work for me. I seemed to get conflicts with other polyfills. Using github fetch instead
import 'whatwg-fetch';
worked and I didn’t need to specify fetch or fetchOptions in the client.