error: createNetworkInterface is not a function on React Native and Apollo Client

error: createNetworkInterface is not a function on React Native and Apollo Client

我一直在尝试在我的 react-native 项目中使用 apollo 客户端,以便我可以连接到一个完全开发的 apollo graphql 服务器。但是,我收到一个错误,表明 createNetworkInterface 不是正确的方法。我应该如何初始化阿波罗客户端? Error from the debugging mobile device

我用来初始化apollo客户端的代码是:

// Initialize the Apollo Client
const client = new ApolloClient({
  networkInterface: createNetworkInterface({
    uri: 'https://api.graph.cool/simple/v1/ciwce5xw82kh7017179gwzn7q',
  }),
})

我真的尽我最大的努力寻找如何实现这个的解决方案,但大多数 tutorials/documentations 是针对 web 的反应,而 none 是针对本机反应。抱歉我的英语不好:(

我以前遇到过同样的问题。不幸的是,除了降级我的 react-apollo 和 react-native 依赖项之外,我找不到任何其他解决方案,如下所示:

yarn add react-apollo@1.0.0

并安装旧版本的 react-native:

react-native init appName --version react-native@0.45.0

你也可以参考一些关于这个问题的话题here and here