我用nodejs10写了下面的代码。
const ApolloClient = require('apollo-boost');
const client = new ApolloClient({
uri: 'http://localhost:8000/graphql'
});我在运行这个程序时得到的错误是:
const client = ApolloClient({
^
TypeError: ApolloClient is not a function以下是依赖关系:
"apollo-boost": "^0.3.1",
"apollo-cache-inmemory": "^1.6.0",
"apollo-client": "^2.6.0",
"apollo-link-http": "^1.5.14",
"apollo-server": "^2.5.0",
"apollo-server-express": "^2.5.1",我按照用户指南设置了一个apollo客户端,以便带到我的服务器上。但它在一开始就失败了。我想知道我的代码出了什么问题。有什么我漏掉的吗?
发布于 2019-05-31 13:06:45
为了初始化Apollo客户端,您必须在配置对象上指定链接和缓存属性。您可以通过使用默认导入来覆盖此设置。
const apollo = require('apollo-boost');
const ApolloClient = apollo.default;
const client = new ApolloClient({
uri: 'http://localhost:8000/graphql'
});发布于 2020-02-02 23:41:51
(‘apollo-boost’)不返回ApolloClient,它返回一个包含ApolloClient的对象。
从ApolloGraphQL/apollo-client上的github issue
// es6 import
import { default as ApolloClient } from 'apollo-boost';
// es5 or Node.js
const Boost = require('apollo-boost');
const ApolloClient = Boost.DefaultClient;https://stackoverflow.com/questions/56388879
复制相似问题