阿波罗升压器第二次不工作缓存的数据

问题描述

我正在使用apollo-boost进行缓存。第一次看到网络呼叫,第二次返回页面时没有网络呼叫,但是缓存的数据是前一页的混合。我有主页和关于页面。我在主页中,转到“关于”页面,然后返回主页,我也从“关于”页面看到数据。
import ApolloClient from 'apollo-boost';
const client = new ApolloClient({ uri: 'http://localhost:4000' });
ReactDOM.render(
        <ApolloProvider client={client}>
          <Container  />
        </ApolloProvider>,document.getElementById('root')
      );

import { ApolloClient,InMemoryCache,ApolloLink,IntrospectionFragmentMatcher } from 'apollo-boost';
import { createPersistedQueryLink } from "apollo-link-persisted-queries";
import introspectionQueryResultData from '../../src/fragmentTypes.json';

const fragmentMatcher = new IntrospectionFragmentMatcher({
  introspectionQueryResultData
});
const cache = new InMemoryCache({
  fragmentMatcher,});
const APIURL = sessionStorage.getItem('REACT_APP_API_URL');
const httpLink = createPersistedQueryLink().concat(createHttpLink({ uri: APIURL }));
const client = new ApolloClient({
  link: authLink.concat(httpLink),// Chain it with the HttpLink
  cache
});

const data = await this.composeQuery(query,params);
async composeQuery(query: any,params: any) {
    const { data,errors } = await client.query({
      query,variables: params
    })
    if (errors) return this.notifyError();

    if (data) return data;
  }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)