【问题标题】:Undefined is not an object (evaluating 'options.cache')未定义不是对象(评估“options.cache”)
【发布时间】:2020-01-09 07:46:15
【问题描述】:

我正在使用带有 Expo 的 Apollo 客户端创建一个反应原生应用程序 尝试在 ios 模拟器中运行应用时出现错误

const MainNavigator = createStackNavigator({
Home: {screen: HomeScreen},
Event: {screen: EventScreen},
});

const client = new ApolloClient();
const RootComponent = createAppContainer(MainNavigator);

const App = () => (
  <ApolloProvider client={client}>
   <RootComponent />
  </ApolloProvider>
);

AppRegistry.registerComponent('Kunkur', () => App);`
export default App;

【问题讨论】:

    标签: react-native apollo


    【解决方案1】:

    你需要添加缓存和链接到 apollo 客户端的选项。

    import { InMemoryCache } from 'apollo-cache-inmemory';
    import { HttpLink } from 'apollo-link-http';
    
    
    const client = new ApolloClient(
    {
      cache: new InMemoryCache(),
      link: new HttpLink(
      {
       uri: 'http://your.graphql.url/graphql'
      })
    }
    

    【讨论】:

      猜你喜欢
      • 2016-12-04
      • 2019-09-26
      • 2019-12-12
      • 2019-08-16
      • 2017-01-16
      • 2020-08-06
      • 2017-05-03
      • 2023-03-07
      • 1970-01-01
      相关资源
      最近更新 更多