我得到了同样的错误。通过使用apollo-client、apollo-cache-inmemory、apollo-link-http包来创建 Apollo 客户端而不是使用 apollo-boost 来解决。
这是代码App.js
import React from 'react'
import ApolloClient from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { HttpLink } from 'apollo-link-http';
const withProvider = (Component) => {
const cache = new InMemoryCache();
const link = new HttpLink({
uri: 'your-url'
})
const client = new ApolloClient({
link,
cache
});
return class extends React.Component {
render() {
return (
<ApolloProvider client={client}>
<Component {...this.props} client={client} />
</ApolloProvider>
)
}
}
}
export default withProvider(App);