[英]ApolloClient is not a constructor react-apollo
I am following this tutorial and trying to implement graphQl. 我正在按照本教程并尝试实现graphQl。 There is an issue with the following line:
以下行存在问题:
const client = new ApolloClient();
Strangely I cannot find anything in the react-apollo
GitHub page for this. 奇怪的是我在
react-apollo
GitHub页面中找不到任何东西。 Is there something stupid that I am doing wrong. 我做错了有什么蠢事吗?
import React, { Component } from 'react';
import ChannelsList from './ChannelsList.js';
import './App.css';
import {
ApolloClient,
gpl,
graphql,
ApolloProvider
} from 'react-apollo';
//issue with this line
const client = new ApolloClient();
const channelsListQuery = `
query ChannelsListQuery {
channels {
id,
name
}
}
`;
const ChannelsListWithData = graphql(channelsListQuery)(ChannelsList);
class App extends Component {
render() {
return (
<ApolloProvider client={client}>
<ChannelsListWithData />
</ApolloProvider>
);
}
}
export default App;
To provide a straightforward answer - ApolloClient is no longer a part of the react-apollo
package, but made it to a package of it's own: apollo-client
. 为了提供一个直截了当的答案 - ApolloClient不再是
react-apollo
软件包的一部分,而是将它变成了一个自己的软件包: apollo-client
。
You may also see it being imported from apollo-boost
, a convenience which "includes some packages that we [Apollo's authors] think are essential to developing with Apollo Client." 您可能还会看到它是从
apollo-boost
导入的,这种方便“包括我们[Apollo的作者]认为对Apollo Client开发必不可少的一些软件包。”
having the same issue here and actually following the same article ( https://dev-blog.apollodata.com/full-stack-react-graphql-tutorial-582ac8d24e3b ) as the OP. 在这里有相同的问题,并且实际上遵循相同的文章( https://dev-blog.apollodata.com/full-stack-react-graphql-tutorial-582ac8d24e3b )作为OP。 The issue is that the article is really old and out of date and I would not recommend using it as a guide (take a look at the comments in the article).
问题是这篇文章真的很旧并且已经过时了,我不建议将它作为指南使用(请看一下文章中的评论)。
For a start I'd recommend looking at the docs. 首先,我建议您查看文档。 This link ( http://graphql.org/graphql-js/ ) in particular is a good starting place for getting something up and running.
这个链接( http://graphql.org/graphql-js/ )特别是一个启动和运行的好起点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.